Esempio n. 1
0
        public void InvokeAsync_DelegatesToInstanceFactoryAndMethodInvoker()
        {
            // Arrange
            object expectedInstance = new object();

            object[] expectedArguments = new object[0];

            IFunctionInstanceEx functionInstance = new Mock <IFunctionInstanceEx>().Object;
            Mock <IJobInstanceFactory <object> > instanceFactoryMock = new Mock <IJobInstanceFactory <object> >(MockBehavior.Strict);

            instanceFactoryMock.Setup(f => f.Create(It.IsAny <IFunctionInstanceEx>()))
            .Returns(expectedInstance)
            .Verifiable();
            IJobInstanceFactory <object> instanceFactory = instanceFactoryMock.Object;

            Mock <IMethodInvoker <object, object> > methodInvokerMock = new Mock <IMethodInvoker <object, object> >(MockBehavior.Strict);

            methodInvokerMock.Setup(i => i.InvokeAsync(expectedInstance, expectedArguments))
            .Returns(Task.FromResult <object>(null))
            .Verifiable();
            IMethodInvoker <object, object> methodInvoker = methodInvokerMock.Object;

            IFunctionInvokerEx product = CreateProductUnderTest(instanceFactory, methodInvoker);

            // Act
            var instance = product.CreateInstance(functionInstance);

            product.InvokeAsync(instance, expectedArguments).GetAwaiter().GetResult();

            // Assert
            instanceFactoryMock.VerifyAll();
            methodInvokerMock.VerifyAll();
        }
        public static object Create(Type baseType, IMethodInvoker invoker)
        {
            object proxy = Create(baseType, typeof(SimpleDispatchProxyAsync));

            ((SimpleDispatchProxyAsync)proxy).SetParams(invoker);
            return(proxy);
        }
		static HttpResponseWrapper()
		{
			string methodName = (Type.GetType("Mono.Runtime") == null) ? "SwitchWriter" : "SetTextWriter";
			MethodInfo method = typeof(HttpResponse).GetMethod(methodName, BindingFlags.Instance | BindingFlags.NonPublic);
			
			_switchWriterMethod = (method == null) ? null : method.CreateInvoker();
		}
Esempio n. 4
0
        protected override void Load()
        {
            base.Load();

            if (!type.IsAbstract)
            {
                var defaultConstructor = type.GetConstructor(Type.EmptyTypes);
                if (defaultConstructor != null)
                {
                    defaultConstructorInvoker = defaultConstructor.CreateInvoker();
                }

                var listConstructor = type.GetConstructor(new[] { typeof(int) });
                if (listConstructor != null)
                {
                    listConstructorInvoker = listConstructor.CreateInvoker();
                }
            }

            allConstructors = type.GetConstructors(ALL_INSTANCE).Select(ConstructorInfo.Preloaded).ToArray();

            allProperties          = type.GetProperties(ALL_INSTANCE).Select(PropertyInfo.Preloaded).ToArray();
            allPropertiesNameIndex = MemberIndex.Build(allProperties, p => p.Name);

            allStaticProperties          = type.GetProperties(ALL_STATIC).Select(PropertyInfo.Preloaded).ToArray();
            allStaticPropertiesNameIndex = MemberIndex.Build(allStaticProperties, p => p.Name);

            allMethods          = type.GetMethods(ALL_INSTANCE).Where(m => !m.IsSpecialName).Select(MethodInfo.Preloaded).ToArray();
            allMethodsNameIndex = MemberIndex.Build(allMethods, m => m.Name);

            allStaticMethods          = type.GetMethods(ALL_STATIC).Where(m => !m.IsSpecialName).Select(MethodInfo.Preloaded).ToArray();
            allStaticMethodsNameIndex = MemberIndex.Build(allStaticMethods, m => m.Name);

            parseMethod = allStaticMethods.SingleOrDefault(m => m.HasParameters <string>() && m.Returns(this, "Parse"));
        }
        public void TestAggregatorWithPojoCompletionStrategy()
        {
            IMessageChannel     input    = (IMessageChannel)_ctx.GetObject("aggregatorWithPojoCompletionStrategyInput");
            EventDrivenConsumer endpoint = (EventDrivenConsumer)_ctx.GetObject("aggregatorWithPojoCompletionStrategy");

            ICompletionStrategy completionStrategy =
                (ICompletionStrategy)
                TestUtils.GetFieldValue(TestUtils.GetFieldValue(endpoint, "_handler"), "_completionStrategy");

            Assert.IsTrue(completionStrategy is CompletionStrategyAdapter);

            //DirectFieldAccessor completionStrategyAccessor = new DirectFieldAccessor(completionStrategy);
            IMethodInvoker invoker = (IMethodInvoker)TestUtils.GetFieldValue(completionStrategy, "_invoker");

            Assert.IsTrue(TestUtils.GetFieldValue(invoker, "_obj") is MaxValueCompletionStrategy);
            Assert.IsTrue(
                ((MethodInfo)TestUtils.GetFieldValue(completionStrategy, "_method")).Name.Equals("CheckCompleteness"));
            input.Send(CreateMessage(1l, "id1", 0, 0, null));
            input.Send(CreateMessage(2l, "id1", 0, 0, null));
            input.Send(CreateMessage(3l, "id1", 0, 0, null));
            IPollableChannel outputChannel = (IPollableChannel)_ctx.GetObject("outputChannel");
            IMessage         reply         = outputChannel.Receive(TimeSpan.Zero);

            Assert.IsNull(reply);
            input.Send(CreateMessage(5l, "id1", 0, 0, null));
            reply = outputChannel.Receive(TimeSpan.Zero);
            Assert.IsNotNull(reply);
            Assert.That(reply.Payload, Is.EqualTo(11l));
        }
Esempio n. 6
0
        public void InvokeAsync_IfLambdaReturnsTaskWhenAllCancelledTaskWithReturnTypes_ReturnsCancelledTask()
        {
            // Arrange
            Func <object, object[], Task <object> > lambda = async(i1, i2) =>
            {
                TaskCompletionSource <object> source = new TaskCompletionSource <object>();
                source.SetCanceled();
                await Task.WhenAll(source.Task);

                return(null);
            };

            IMethodInvoker <object, object> invoker = CreateProductUnderTest(lambda);
            object instance = null;

            object[] arguments = null;

            // Act
            Task task = invoker.InvokeAsync(instance, arguments);

            // Assert
            Assert.NotNull(task);
            task.WaitUntilCompleted();
            Assert.Equal(TaskStatus.Canceled, task.Status);
        }
Esempio n. 7
0
        public void Create_IfInOutByRefMethodReturnsTask_RoundtripsArguments(bool isInstance)
        {
            // Arrange
            MethodInfo method           = GetMethodInfo(isInstance, "TestInOutByRefReturnTask");
            int        expectedA        = 1;
            string     expectedInitialB = "B";
            string     expectedFinalB   = "b";

            object[] expectedC = new object[] { new object(), default(int), String.Empty };

            // Act
            IMethodInvoker <MethodInvokerFactoryTests> invoker =
                MethodInvokerFactory.Create <MethodInvokerFactoryTests>(method);

            // Assert
            Assert.NotNull(invoker);
            bool             callbackCalled = false;
            InOutRefTaskFunc callback       = delegate(int a, ref string b, out object[] c)
            {
                callbackCalled = true;
                Assert.Equal(expectedA, a);
                Assert.Same(expectedInitialB, b);
                b = expectedFinalB;
                c = expectedC;
                return(Task.FromResult(0));
            };
            MethodInvokerFactoryTests instance = GetInstance(isInstance);

            object[] arguments = new object[] { expectedA, expectedInitialB, null, callback };
            invoker.InvokeAsync(instance, arguments).GetAwaiter().GetResult();
            Assert.True(callbackCalled);
            Assert.Same(expectedFinalB, arguments[1]);
            Assert.Same(expectedC, arguments[2]);
        }
Esempio n. 8
0
        public void Create_IfMultipleOutputParameters_SetsOutputArguments(bool isInstance)
        {
            // Arrange
            MethodInfo method    = GetMethodInfo(isInstance, "TestOutIntStringObjectArray");
            int        expectedA = 1;
            string     expectedB = "B";

            object[] expectedC = new object[] { new object() };

            // Act
            IMethodInvoker <MethodInvokerFactoryTests> invoker =
                MethodInvokerFactory.Create <MethodInvokerFactoryTests>(method);

            // Assert
            Assert.NotNull(invoker);
            bool      callbackCalled = false;
            OutAction callback       = delegate(out int a, out string b, out object[] c)
            {
                callbackCalled = true;
                a = expectedA;
                b = expectedB;
                c = expectedC;
            };
            MethodInvokerFactoryTests instance = GetInstance(isInstance);

            object[] arguments = new object[] { default(int), null, null, callback };
            invoker.InvokeAsync(instance, arguments).GetAwaiter().GetResult();
            Assert.True(callbackCalled);
            Assert.Equal(expectedA, arguments[0]);
            Assert.Same(expectedB, arguments[1]);
            Assert.Same(expectedC, arguments[2]);
        }
Esempio n. 9
0
        public void InvokeAsync_IfLambdaReturnsTaskWhenAllFaultedTask_ReturnsFaultedTask()
        {
            // Arrange
            Exception expectedException = new InvalidOperationException();
            Func <object, object[], Task <object> > lambda = async(i1, i2) =>
            {
                Task innerTask = new Task(() => { throw expectedException; });
                innerTask.Start();
                Assert.False(innerTask.GetType().IsGenericType); // Guard
                await Task.WhenAll(innerTask);

                return(null);
            };

            IMethodInvoker <object, object> invoker = CreateProductUnderTest(lambda);
            object instance = null;

            object[] arguments = null;

            // Act
            Task task = invoker.InvokeAsync(instance, arguments);

            // Assert
            Assert.NotNull(task);
            task.WaitUntilCompleted();
            Assert.Equal(TaskStatus.Faulted, task.Status);
            Assert.NotNull(task.Exception);
            Assert.Same(expectedException, task.Exception.InnerException);
        }
Esempio n. 10
0
        public void InvokeAsync_DelegatesToLambda()
        {
            // Arrange
            object expectedInstance = new object();

            object[] expectedArguments = new object[0];
            bool     invoked           = false;
            object   instance          = null;

            object[] arguments = null;
            Func <object, object[], Task <object> > lambda = (i, a) =>
            {
                invoked   = true;
                instance  = i;
                arguments = a;
                return(Task.FromResult <object>(null));
            };

            IMethodInvoker <object, object> invoker = CreateProductUnderTest(lambda);

            // Act
            Task task = invoker.InvokeAsync(expectedInstance, expectedArguments);

            // Assert
            Assert.NotNull(task);
            task.GetAwaiter().GetResult();
            Assert.True(invoked);
            Assert.Same(expectedInstance, instance);
            Assert.Same(expectedArguments, arguments);
        }
Esempio n. 11
0
        public void Create_IfMultipleInputParameters_PassesInputArguments(bool isInstance)
        {
            // Arrange
            MethodInfo method    = GetMethodInfo(isInstance, "TestIntStringObjectArray");
            int        expectedA = 1;
            string     expectedB = "B";

            object[] expectedC = new object[] { new object() };

            // Act
            IMethodInvoker <MethodInvokerFactoryTests> invoker =
                MethodInvokerFactory.Create <MethodInvokerFactoryTests>(method);

            // Assert
            Assert.NotNull(invoker);
            bool callbackCalled = false;
            Action <int, string, object> callback = (a, b, c) =>
            {
                callbackCalled = true;
                Assert.Equal(expectedA, a);
                Assert.Same(expectedB, b);
                Assert.Same(expectedC, c);
            };
            MethodInvokerFactoryTests instance = GetInstance(isInstance);

            object[] arguments = new object[] { expectedA, expectedB, expectedC, callback };
            invoker.InvokeAsync(instance, arguments).GetAwaiter().GetResult();
            Assert.True(callbackCalled);
        }
Esempio n. 12
0
        public static T Create <T>(IMethodInvoker invoker) where T : class
        {
            object proxy = Create <T, SimpleDispatchProxyAsync>();

            ((SimpleDispatchProxyAsync)proxy).SetParams(invoker);
            return((T)proxy);
        }
Esempio n. 13
0
        static HttpResponseWrapper()
        {
            string     methodName = (Type.GetType("Mono.Runtime") == null) ? "SwitchWriter" : "SetTextWriter";
            MethodInfo method     = typeof(HttpResponse).GetMethod(methodName, BindingFlags.Instance | BindingFlags.NonPublic);

            _switchWriterMethod = (method == null) ? null : method.CreateInvoker();
        }
Esempio n. 14
0
 private static FunctionInvoker <TReflected, TReturnValue> CreateProductUnderTest <TReflected, TReturnValue>(
     IReadOnlyList <string> parameterNames,
     IJobInstanceFactory <TReflected> instanceFactory,
     IMethodInvoker <TReflected, TReturnValue> methodInvoker)
 {
     return(new FunctionInvoker <TReflected, TReturnValue>(parameterNames, instanceFactory, methodInvoker));
 }
Esempio n. 15
0
        private object DoInvokeMethod(MethodInfo method, object[] args, IMessage message)
        {
            object         result  = null;
            IMethodInvoker invoker = null;

            try {
                invoker = invokers.ContainsKey(method) ? invokers[method] : null;
                if (invoker == null)
                {
                    invoker = new DefaultMethodInvoker(_obj, method);
                    invokers.Add(method, invoker);
                }
                result = invoker.InvokeMethod(args);
            }
            catch (ArgumentException e) {
                try {
                    if (message != null)
                    {
                        result = invoker.InvokeMethod(message);
                        methodsExpectingMessage.Add(method);
                    }
                }
                catch (Exception ex) { //TODO NoSuchMethodException e2) {
                    throw new MessageHandlingException(message, "unable to resolve method for args: " + StringUtils.ArrayToCommaDelimitedString(args), ex);
                }
            }
            return(result == null || result.GetType().Equals(typeof(Missing)) ? null : result);
        }
Esempio n. 16
0
        public void InvokeAsync_IfLambdaReturnsTaskWhenAllCancelledTask_ReturnsCancelledTask()
        {
            // Arrange
            Func <object, object[], Task <object> > lambda = async(i1, i2) =>
            {
                var  cancellationSource = new System.Threading.CancellationTokenSource();
                Task innerTask          = new Task(() => { }, cancellationSource.Token);
                Assert.False(innerTask.GetType().IsGenericType); // Guard
                cancellationSource.Cancel();
                await Task.WhenAll(innerTask);

                return(null);
            };

            IMethodInvoker <object, object> invoker = CreateProductUnderTest(lambda);
            object instance = null;

            object[] arguments = null;

            // Act
            Task task = invoker.InvokeAsync(instance, arguments);

            // Assert
            Assert.NotNull(task);
            task.WaitUntilCompleted();
            Assert.Equal(TaskStatus.Canceled, task.Status);
        }
Esempio n. 17
0
        public void InvokeAsync_IfInstanceIsDisposable_DoesNotDisposeWhileTaskIsRunning()
        {
            // Arrange
            bool disposed = false;

            Mock <IDisposable> disposableMock = new Mock <IDisposable>(MockBehavior.Strict);

            disposableMock.Setup(d => d.Dispose()).Callback(() => { disposed = true; });
            IDisposable disposable = disposableMock.Object;

            IFactory <object>             instanceFactory = CreateStubFactory(disposable);
            TaskCompletionSource <object> taskSource      = new TaskCompletionSource <object>();
            IMethodInvoker <object>       methodInvoker   = CreateStubMethodInvoker(taskSource.Task);

            IFunctionInvoker product = CreateProductUnderTest(instanceFactory, methodInvoker);

            object[] arguments = new object[0];

            // Act
            Task task = product.InvokeAsync(arguments);

            // Assert
            Assert.NotNull(task);
            Assert.False(disposed);
            taskSource.SetResult(null);
            task.GetAwaiter().GetResult();
        }
Esempio n. 18
0
        public void InvokeAsync_IfLambdaReturnsFaultedTask_ReturnsFaultedTask()
        {
            // Arrange
            Exception expectedException = new InvalidOperationException();
            Func <object, object[], Task <object> > lambda = (i1, i2) =>
            {
                TaskCompletionSource <object> source = new TaskCompletionSource <object>();
                source.SetException(expectedException);
                return(source.Task);
            };

            IMethodInvoker <object, object> invoker = CreateProductUnderTest(lambda);
            object instance = null;

            object[] arguments = null;

            // Act
            Task task = invoker.InvokeAsync(instance, arguments);

            // Assert
            Assert.NotNull(task);
            task.WaitUntilCompleted();
            Assert.Equal(TaskStatus.Faulted, task.Status);
            Assert.NotNull(task.Exception);
            Assert.Same(expectedException, task.Exception.InnerException);
        }
Esempio n. 19
0
        private static IFunctionInvoker CreateGeneric <TReflected, TReturnValue>(MethodInfo method, IMethodInvokerFactory methodInvokerFactory, IFunctionActivator functionActivator)
        {
            List <string?> parameterNames = method.GetParameters().Select(p => p.Name).ToList();

            IMethodInvoker <TReflected, TReturnValue> methodInvoker = methodInvokerFactory.Create <TReflected, TReturnValue>(method);

            return(new DefaultFunctionInvoker <TReflected, TReturnValue>(methodInvoker, functionActivator));
        }
Esempio n. 20
0
 public ActivationData(Addressable addressable, IMethodInvoker methodInvoker, Type interfaceType, Priority priority, InvokeContextCategory invokeContextCategory)
 {
     this.addressable           = addressable;
     this.methodInvoker         = methodInvoker;
     this.interfaceType         = interfaceType;
     this.priority              = priority;
     this.invokeContextCategory = invokeContextCategory;
 }
Esempio n. 21
0
 public FormEngine(IParameterProvider parameterProvider,
                   IViewRenderer viewRenderer, IFormPersister formPersister, IMethodInvoker methodInvoker)
 {
     _parameterProvider = parameterProvider;
     _viewRenderer      = viewRenderer;
     _formPersister     = formPersister;
     _methodInvoker     = methodInvoker;
 }
 public JsClr(IJintVisitor visitor)
 {
     this.global         = visitor.Global;
     this.propertyGetter = visitor.PropertyGetter;
     this.methodGetter   = visitor.MethodGetter;
     this.fieldGetter    = visitor.FieldGetter;
     value = null;
 }
Esempio n. 23
0
        public JsClr(IJintVisitor visitor)
        {
            this.global = visitor.Global;
            this.propertyGetter = visitor.PropertyGetter;
            this.methodGetter = visitor.MethodGetter;
            this.fieldGetter = visitor.FieldGetter;
            value = null;

        }
Esempio n. 24
0
 internal BackgroundDispatcher(IMethodInvoker etwActivityMethodInvoker)
 {
     if (etwActivityMethodInvoker == null)
     {
         throw new ArgumentNullException("etwActivityMethodInvoker");
     }
     this._etwActivityMethodInvoker = etwActivityMethodInvoker;
     this._invokerWaitCallback      = new WaitCallback(this.DoInvoker);
 }
Esempio n. 25
0
 internal BackgroundDispatcher(IMethodInvoker etwActivityMethodInvoker)
 {
     if (etwActivityMethodInvoker == null)
     {
         throw new ArgumentNullException("etwActivityMethodInvoker");
     }
     this._etwActivityMethodInvoker = etwActivityMethodInvoker;
     this._invokerWaitCallback = new WaitCallback(this.DoInvoker);
 }
Esempio n. 26
0
 public FunctionInvoker(
     IReadOnlyList <string> parameterNames,
     IJobInstanceFactory <TReflected> instanceFactory,
     IMethodInvoker <TReflected, TReturnValue> methodInvoker)
 {
     _parameterNames  = parameterNames ?? throw new ArgumentNullException(nameof(parameterNames));
     _instanceFactory = instanceFactory ?? throw new ArgumentNullException(nameof(instanceFactory));
     _methodInvoker   = methodInvoker ?? throw new ArgumentNullException(nameof(methodInvoker));
 }
Esempio n. 27
0
        public static IMethodInvoker GetMethodInvoker(MethodInfo methodInfo)
        {
            if (!m_MethodInvokerDict.ContainsKey(methodInfo)){
                IMethodInvoker invoker = CreateMethodInvoker(methodInfo);
                m_MethodInvokerDict.Add(methodInfo, invoker);
                return invoker;
            }

            return m_MethodInvokerDict[methodInfo];
        }
Esempio n. 28
0
 public ServiceDescriptor(string route, MethodInfo serverMethodInfo, MethodInfo clientMethodInfo, IMethodInvoker methodInvoker, List <Type> serverInterceptors, List <Type> clientInterceptors, ServiceCircuitBreakerOptions serviceCircuitBreakerOptions, CachingConfig cachingConfig)
 {
     Route                        = route;
     ServerMethodInfo             = serverMethodInfo;
     ClientMethodInfo             = clientMethodInfo;
     MethodInvoker                = methodInvoker;
     ServerInterceptors           = serverInterceptors;
     ClientInterceptors           = clientInterceptors;
     ServiceCircuitBreakerOptions = serviceCircuitBreakerOptions;
     CachingConfig                = cachingConfig;
 }
Esempio n. 29
0
        /// <summary>
        /// Search for the <see cref="ClassifierAttribute"/> attribute on a method in
        /// the supplied delegate and use that to create a
        /// <see cref="IClassifier{C,T}"/> from the parameter type to the return type.
        /// If the attribute is not found a unique non-void method with a
        /// single parameter will be used, if it exists. The signature of the method
        /// cannot be checked here, so might be a runtime exception when the method
        /// is invoked if the signature doesn't match the classifier types.
        /// </summary>
        /// <param name="classifierDelegate">The classifier delegate.</param>
        public void SetDelegate(object classifierDelegate)
        {
            this.classifier = null;
            this.invoker    = MethodInvokerUtils.GetMethodInvokerByAttribute(typeof(ClassifierAttribute), classifierDelegate);
            if (this.invoker == null)
            {
                this.invoker = MethodInvokerUtils.GetMethodInvokerForSingleArgument(classifierDelegate);
            }

            AssertUtils.State(this.invoker != null, "No single argument public method with or without [Classifier] was found in delegate of type " + classifierDelegate.GetType().Name);
        }
        public void Create_IfStaticMethodReturnsTask_ReturnsVoidTaskInvoker(bool isInstance)
        {
            // Arrange
            MethodInfo method = GetMethodInfo(isInstance, "ReturnTask");

            // Act
            IMethodInvoker <DefaultMethodInvokerFactoryTests, object> invoker =
                _methodInvokerFactory.Create <DefaultMethodInvokerFactoryTests, object>(method);

            // Assert
            Assert.IsType <VoidTaskMethodInvoker <DefaultMethodInvokerFactoryTests, object> >(invoker);
        }
Esempio n. 31
0
        public void Create_IfStaticMethodReturnsTask_ReturnsTaskInvoker(bool isInstance)
        {
            // Arrange
            MethodInfo method = GetMethodInfo(isInstance, "ReturnTask");

            // Act
            IMethodInvoker <MethodInvokerFactoryTests> invoker =
                MethodInvokerFactory.Create <MethodInvokerFactoryTests>(method);

            // Assert
            Assert.IsType <TaskMethodInvoker <MethodInvokerFactoryTests> >(invoker);
        }
Esempio n. 32
0
 internal NullCheckAsserter(
     IParameterListBuilder paramBuilder,
     IMemberFinder memberFinder,
     IMethodInvoker methodInvoker)
 {
     Guard.AgainstNull(paramBuilder, nameof(paramBuilder));
     Guard.AgainstNull(memberFinder, nameof(memberFinder));
     Guard.AgainstNull(methodInvoker, nameof(methodInvoker));
     this.paramBuilder  = paramBuilder;
     this.memberFinder  = memberFinder;
     this.methodInvoker = methodInvoker;
 }
Esempio n. 33
0
        private static IFunctionInvoker CreateGeneric <TReflected>(MethodInfo method, IJobActivator activator)
        {
            Debug.Assert(method != null);

            List <string> parameterNames = method.GetParameters().Select(p => p.Name).ToList();

            IMethodInvoker <TReflected> methodInvoker = MethodInvokerFactory.Create <TReflected>(method);

            IFactory <TReflected> instanceFactory = CreateInstanceFactory <TReflected>(method, activator);

            return(new FunctionInvoker <TReflected>(parameterNames, instanceFactory, methodInvoker));
        }
Esempio n. 34
0
        public ExecutionVisitor(Options options)
        {
            this.methodInvoker = new CachedMethodInvoker(this);
            this.propertyGetter = new CachedReflectionPropertyGetter(methodInvoker);
            this.constructorInvoker = new CachedConstructorInvoker(methodInvoker);
            this.typeResolver = new CachedTypeResolver();
            this.fieldGetter = new CachedReflectionFieldGetter(methodInvoker);

            GlobalScope = new JsObject();
            Global = new JsGlobal(this, options);
            GlobalScope.Prototype = Global as JsDictionaryObject;
            EnterScope(GlobalScope);
            CallStack = new Stack<string>();
        }
Esempio n. 35
0
        public ExecutionVisitor(Options options, IScriptEngineContext context)
        {
            this.scriptEngineContext = context;
            this.methodInvoker = context.GetMethodInvoker(this);//new CachedMethodInvoker(this);
            this.propertyGetter = new CachedReflectionPropertyGetter(methodInvoker);
            this.constructorInvoker = new CachedConstructorInvoker(methodInvoker);
            this.typeResolver = context.GetTypeResolver();//new CachedTypeResolver();
            this.fieldGetter = new CachedReflectionFieldGetter(methodInvoker);
            _entitiyAccessor = new EntityAccessor();

            GlobalScope = new JsObject();
            Global = new JsGlobal(this, options);
            GlobalScope.Prototype = Global as JsDictionaryObject;
            EnterScope(GlobalScope);
            CallStack = new Stack<string>();
        }
Esempio n. 36
0
 public TFlowEngine(ILoggerFactory factory
     , IUserService userService
     , IAgentService agentService
     , IWorkItemService workItemService
     , IProcessService processService
     , IProcessTypeService processTypeService
     , ITimeZoneService timeZoneService
     , IWorkflowParser workflowParser
     , IMethodInvoker invoker
     ,ISchedulerService schedulerService)
 {
     this._log = factory.Create(typeof(TFlowEngine));
     this._userService = userService;
     this._agentService = agentService;
     this._workItemService = workItemService;
     this._processService = processService;
     this._processTypeService = processTypeService;
     this._timeZoneService = timeZoneService;
     this._workflowParser = workflowParser;
     this._invoker = invoker;
     this._schedulerService = schedulerService;
 }
Esempio n. 37
0
 public void OnDeserialization(object sender)
 {
     this.methodInvoker = new CachedMethodInvoker(this);
     this.propertyGetter = new CachedReflectionPropertyGetter(methodInvoker);
     this.constructorInvoker = new CachedConstructorInvoker(methodInvoker);
     this.typeResolver = new CachedTypeResolver();
     this.fieldGetter = new CachedReflectionFieldGetter(methodInvoker);
 }
 public CachedReflectionFieldGetter(IMethodInvoker methodInvoker)
 {
     this.methodInvoker = methodInvoker;
 }
 public CachedConstructorInvoker(IMethodInvoker methodInvoker)
 {
     this.methodInvoker = methodInvoker;
 }
 public void ShouldThrowExceptionIfNullFormatterPassedIn()
 {
     _methodInvoker = new DefaultMethodInvoker(null);
 }
 public void Init()
 {
     _formatter = new Mock<IRequestFormatter>();
     _methodInvoker = new DefaultMethodInvoker(_formatter.Object);
 }
Esempio n. 42
0
 public void SetUp()
 {
     DefaultMethodInvoker = MethodInvoker.Invoker;
 }
 public CachedReflectionPropertyGetter(IMethodInvoker invoker)
 {
     methodInvoker = invoker;
 }
 public void AfterPropertiesSet()
 {
     if(method != null) {
         invoker = new DefaultMethodInvoker(obj, method);
     }
     else if(methodName != null) {
         NameResolvingMethodInvoker nrmi = new NameResolvingMethodInvoker(obj, methodName);
         nrmi.MethodValidator = new MessageReceivingMethodValidator();
         invoker = nrmi;
     }
     else {
         throw new ArgumentException("either 'method' or 'methodName' is required");
     }
 }