/// <summary> /// Initializes a new instance of the <see cref="Method{TSignature}"/> class. /// </summary> internal Method(Method method, IDelegateFactory <MethodInfo> delegateFactory) : base(NotNull(method).Info, method.Instance) { if (!delegateFactory.TryCreate(Instance, Info, out @delegate !)) { string error = $"Method {method.Info} doesn't match expected signature."; throw new ArgumentException(error, nameof(method)); } }
internal Constructor(Constructor constructor, IDelegateFactory <ConstructorInfo> delegateFactory) : base(NotNull(constructor).Info, constructor.Instance) { if (!delegateFactory.TryCreate(Instance, Info, out @delegate !)) { string error = $"Constructor {constructor.Info} doesn't match expected signature."; throw new ArgumentException(error, nameof(constructor)); } }
public static Action <T?, TMember?>?CreateSetter <T, TMember>(this IDelegateFactory factory, string name, bool extension) { var pi = typeof(T).GetRuntimeProperty(name); if (pi is null) { throw new ArgumentException("Invalid name.", nameof(name)); } return(factory.CreateSetter <T, TMember>(pi, extension)); }
internal static bool TryCreate <TMethodBase, TDelegate>(this IDelegateFactory <TMethodBase> delegateFactory, object?target, TMethodBase method, out TDelegate? @delegate) where TMethodBase : MethodBase where TDelegate : Delegate { if (delegateFactory == null) { throw new ArgumentNullException(nameof(delegateFactory)); } bool created = delegateFactory.TryCreate(typeof(TDelegate), target, method, out Delegate? d); @delegate = (TDelegate?)d; return(created); }
public MethodTypeFilter(IEnumerable <Method> source, Type delegateType, IDelegateFactory <MethodInfo> delegateFactory) : base(source) { if (delegateType == null) { throw new ArgumentNullException(nameof(delegateType)); } if (!typeof(Delegate).IsAssignableFrom(delegateType)) { throw new ArgumentException($"{delegateType} is not a delegate.", nameof(delegateType)); } DelegateType = delegateType; DelegateFactory = delegateFactory ?? throw new ArgumentNullException(nameof(delegateFactory)); }
public Delegate CreateSynchronizedDelegate(Delegate del) { lock (delegateFactories.SyncRoot) { Type delType = del.GetType(); IDelegateFactory factory = delegateFactories [delType] as IDelegateFactory; if (factory == null) { Type t = GetDelegateFactoryType(delType); factory = Activator.CreateInstance(t) as IDelegateFactory; delegateFactories [delType] = factory; } return(factory.Create(del, this)); } }
public static void SetFactory(IDelegateFactory factory) { }
internal DependencyStrapper(IDelegateFactory delegateFactory) { _delegateFactory = delegateFactory; }
internal void Initialize() { delegateFactoryType = DelegateFactoryType.Expression; delegateFactory = new ExpressionDelegateFactory(); }