public AsyncFunctionFactoryStub(IBindingRequest request, Type targetObjectType,
                                 ForwardFuncToMethodCall asyncInitializerFactory)
 {
     this.request                 = request;
     this.targetObjectType        = targetObjectType;
     this.asyncInitializerFactory = asyncInitializerFactory;
 }
 public FunctionActivationStrategy(Type functionDelegateType)
 {
     resultType = functionDelegateType.GetGenericArguments().Last();
     this.functionDelegateType = functionDelegateType;
     forwardFuncToMethodCall   = new ForwardFuncToMethodCall(functionDelegateType,
                                                             nameof(FunctionFactoryImplementation.CreateTargetObject),
                                                             typeof(FunctionFactoryImplementation));
 }
예제 #3
0
        public void CompileIntFactory()
        {
            var target = new ObjectTarget();
            var fact   = new ForwardFuncToMethodCall(typeof(Func <int, string>), nameof(ObjectTarget.SetDestination),
                                                     typeof(ObjectTarget));

            var f = (Func <int, string>)fact.CreateFuncDelegate(target);

            Assert.Equal("Return Value:101", f(101));
        }
 public AsyncFunctionActivationStrategy(Type outerFunctionType)
 {
     innerFunctionType = ReturnType(outerFunctionType);
     targetObjectType  = GetTypeFromFuncOrTask(innerFunctionType);
     if (IsTask(innerFunctionType))
     {
         staticCreatorFactory             = asyncInitializerFactory
                                          = new ForwardFuncToMethodCall(outerFunctionType,
                                                                        nameof(AsyncFunctionFactoryStub.CallStaticFunc),
                                                                        typeof(AsyncFunctionFactoryStub));
     }
     else
     {
         staticCreatorFactory = new ForwardFuncToMethodCall(outerFunctionType,
                                                            nameof(AsyncFunctionFactoryStub.CreateAsyncInitializerFunc),
                                                            typeof(AsyncFunctionFactoryStub));
         asyncInitializerFactory = MakeAsyncInitializerFactory();
     }
 }