Ejemplo n.º 1
0
        private void EventThreadLoop()
        {
            while (!IsInvalid)
            {
                DelegateInvoker invoker = null;

                lock (_eventQueueLock)
                {
                    if (_eventQueue.Count == 0)
                    {
                        Monitor.Wait(_eventQueueLock);
                    }

                    if (_eventQueue.Count > 0)
                    {
                        invoker = _eventQueue.Dequeue();
                    }
                }

                if (invoker != null)
                {
                    try
                    {
                        invoker.Execute();
                    }
                    catch (Exception ex)
                    {
                        OnException(new SessionEventArgs(ex.ToString()));
                    }
                }
            }

            Debug.WriteLine("Event loop exiting");
        }
Ejemplo n.º 2
0
 internal void Queue(DelegateInvoker delegateInvoker)
 {
     lock (_eventQueueLock)
     {
         _eventQueue.Enqueue(delegateInvoker);
         Monitor.Pulse(_eventQueueLock);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Removes an observer so that it stop receiving events and is no longer referenced.
        /// </summary>
        /// <typeparam name="T">the type of event</typeparam>
        /// <param name="observer">the object that will receive events</param>
        public void Unsubscribe <T>(IEventObserver <T> handler = default) where T : unmanaged, IComponentData
        {
            int typeIndex = TypeManager.GetTypeIndex <T>();
            var invoker   = new DelegateInvoker <T> {
                Handler = handler
            };

            _dispatcherSystem.Remove(typeIndex, invoker);
        }
Ejemplo n.º 4
0
        internal void Initialize(
            EmitMapperManager MapperMannager,
            Type TypeFrom,
            Type TypeTo,
            IMappingConfigurator mappingConfigurator,
            object[] stroredObjects)
        {
            mapperMannager       = MapperMannager;
            typeFrom             = TypeFrom;
            typeTo               = TypeTo;
            _mappingConfigurator = mappingConfigurator;
            StroredObjects       = stroredObjects;
            if (_mappingConfigurator != null)
            {
                _rootOperation = _mappingConfigurator.GetRootMappingOperation(TypeFrom, TypeTo);
                if (_rootOperation == null)
                {
                    _rootOperation = new RootMappingOperation(TypeFrom, TypeTo);
                }
                var constructor = _rootOperation.TargetConstructor;
                if (constructor != null)
                {
                    _targetConstructor = (DelegateInvokerFunc_0)DelegateInvoker.GetDelegateInvoker(constructor);
                }

                var valuesPostProcessor = _rootOperation.ValuesPostProcessor;
                if (valuesPostProcessor != null)
                {
                    _valuesPostProcessor = (DelegateInvokerFunc_2)DelegateInvoker.GetDelegateInvoker(valuesPostProcessor);
                }

                var converter = _rootOperation.Converter;
                if (converter != null)
                {
                    _converter = (DelegateInvokerFunc_2)DelegateInvoker.GetDelegateInvoker(converter);
                }

                var nullSubstitutor = _rootOperation.NullSubstitutor;
                if (nullSubstitutor != null)
                {
                    _nullSubstitutor = (DelegateInvokerFunc_0)DelegateInvoker.GetDelegateInvoker(nullSubstitutor);
                }

                var sourceFilter = _rootOperation.SourceFilter;
                if (sourceFilter != null)
                {
                    _sourceFilter = (DelegateInvokerFunc_2)DelegateInvoker.GetDelegateInvoker(sourceFilter);
                }

                var destinationFilter = _rootOperation.DestinationFilter;
                if (destinationFilter != null)
                {
                    _destinationFilter = (DelegateInvokerFunc_2)DelegateInvoker.GetDelegateInvoker(destinationFilter);
                }
            }
        }
Ejemplo n.º 5
0
        private void DelegateControllerTest(Mock <IParentInterface> mock)
        {
            DelegateInvoker invoker = mock.Expects.One.DelegateBinding(_ => _.Delegate += null);

            var controller = new DelegateController(mock.MockObject);

            invoker.Invoke("Input 1");

            Assert.AreEqual("Input 1", controller.Input);
        }
Ejemplo n.º 6
0
        private void AddHandlerEmptyDelegateBindingTest(Mock <IParentInterface> mock)
        {
            int             i        = 0;
            DelegateInvoker invoker1 = mock.Expects.One.DelegateBinding(e => e.Delegate += delegate { });

            mock.MockObject.Delegate += delegate { i++; };

            invoker1.Invoke("message 5");

            Assert.AreEqual(1, i);
        }
Ejemplo n.º 7
0
        private void AddHandlerAnonymousBindingTest(Mock <IParentInterface> mock)
        {
            int             i        = 0;
            DelegateInvoker invoker1 = mock.Expects.One.DelegateBinding(e => e.Delegate += (msg) => { });

            mock.MockObject.Delegate += (m) => { i++; };

            invoker1.Invoke("message 4");

            Assert.AreEqual(1, i);
        }
Ejemplo n.º 8
0
        public static ArrayList EnumDelegatesFrom(Delegate method, DelegateInvoker callback)
        {
            Delegate[] dgs  = method.GetInvocationList();
            ArrayList  rlts = new ArrayList();

            foreach (Delegate dg in dgs)
            {
                rlts.Add(callback(dg));
            }
            return(rlts);
        }
Ejemplo n.º 9
0
        public void EmitInvokerTest_TestCall2()
        {
            var caller = (DelegateInvokerFunc_0)DelegateInvoker.GetDelegateInvoker((Func <int>)(() => 3));

            Assert.Equal(3, caller.CallFunc());

            var caller2 = (DelegateInvokerFunc_2)DelegateInvoker.GetDelegateInvoker((Func <int, int, int>)((l, r) => l + r));

            //DynamicAssemblyManager.SaveAssembly();
            Assert.Equal(5, caller2.CallFunc(2, 3));
        }
Ejemplo n.º 10
0
        private void AddHandlerNullBindingTest(Mock <IParentInterface> mock)
        {
            _message = null;

            DelegateInvoker invoker1 = mock.Expects.One.DelegateBinding(e => e.Delegate += null);

            mock.MockObject.Delegate += Listener;

            invoker1.Invoke("message 1");

            Assert.AreEqual("message 1", _message);
        }
Ejemplo n.º 11
0
        private void RemoveHandlerAndInvokeTest(Mock <IParentInterface> mock)
        {
            _message = null;

            DelegateInvoker invoker = mock.Expects.One.DelegateBinding(_ => _.Delegate -= Listener);

            mock.MockObject.Delegate -= Listener;

            invoker.Invoke("message 2");

            Assert.IsNull(_message);
        }
Ejemplo n.º 12
0
        public void FiresEventOnInvocationReceiver()
        {
            MockFactory  factory = new MockFactory();
            Mock <IBell> mock    = factory.CreateMock <IBell>();

            DelegateInvoker invoker = mock.Expects.One.DelegateBinding(_ => _.Listeners += Salivate);

            mock.MockObject.Listeners += Salivate;

            invoker.Invoke("Rover");

            Assert.AreEqual("Rover", dog);
            factory.VerifyAllExpectationsHaveBeenMet();
        }
    public void EmitInvokerTest_TestCall1()
    {
        var i      = 0;
        var caller = (DelegateInvokerAction0)DelegateInvoker.GetDelegateInvoker((Action)(() => i++));

        caller.CallAction();
        caller.CallAction();
        caller.CallAction();
        i.ShouldBe(3);

        var caller2 = (DelegateInvokerAction0)DelegateInvoker.GetDelegateInvoker((Action)(() => i += 2));

        caller2.CallAction();
        caller2.CallAction();
        i.ShouldBe(7);
    }
Ejemplo n.º 14
0
        public void EmitInvokerTest_TestCall1()
        {
            int i      = 0;
            var caller = (DelegateInvokerAction_0)DelegateInvoker.GetDelegateInvoker((Action)(() => i++));

            caller.CallAction();
            caller.CallAction();
            caller.CallAction();
            Assert.Equal(3, i);

            var caller2 = (DelegateInvokerAction_0)DelegateInvoker.GetDelegateInvoker((Action)(() => i += 2));

            caller2.CallAction();
            caller2.CallAction();
            Assert.Equal(7, i);
        }
Ejemplo n.º 15
0
        private void ThrowErrorOnInvokeTest(Mock <IParentInterface> mock)
        {
            DelegateInvoker invoker = mock.Expects.One.DelegateBinding(_ => _.Delegate += ThrowListener);

            mock.MockObject.Delegate += ThrowListener;             //binding to a listener that throws

#if SILVERLIGHT
            Expect.That(() => invoker.Invoke("message 3")).Throws <TargetInvocationException>(new StringContainsMatcher(@"System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: message 3
   at NMockTests.MockTests.ExpectsTests.IMethodSyntaxTestsSL.DelegateBindingTests.ThrowListener(String message)"));
#else
#if NetFx35
            Expect.That(() => invoker.Invoke("message 3")).Throws <InvalidOperationException>(new StringContainsMatcher(@"System.InvalidOperationException: message 3
   at NMockTests.MockTests.ExpectsTests.IMethodSyntaxTests35.DelegateBindingTests.ThrowListener(String message)"));
#else
            Expect.That(() => invoker.Invoke("message 3")).Throws <InvalidOperationException>(new StringContainsMatcher(@"System.InvalidOperationException: message 3
   at NMockTests.MockTests.ExpectsTests.IMethodSyntaxTests.DelegateBindingTests.ThrowListener(String message)"));
#endif
#endif
        }
Ejemplo n.º 16
0
 public virtual void Intercept(IInvocation invocation)
 {
     if (uiItem == null)
     {
         uiItem = window.Get(searchCriteria);
         if (uiItem == null)
         {
             throw new UIItemSearchException("Could not find UIItem with, " + searchCriteria);
         }
     }
     try
     {
         var invoker = DelegateInvoker.CreateInvoker(uiItem, invocation.Method);
         invocation.ReturnValue = invoker.Call(invocation.Arguments);
     }
     catch (Exception)
     {
         sessionReport.Act();
         throw;
     }
 }
Ejemplo n.º 17
0
        public void can_invoke_all_void_overloads()
        {
            var targetType = typeof(ITarget);
            var target     = Substitute.For <ITarget>();

            DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Void")).Call(new object[0]);
            target.Received().Void();

            DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Void1")).Call(new object[] { 1 });
            target.Received().Void1(1);

            DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Void2")).Call(new object[] { 1, 2 });
            target.Received().Void2(1, 2);

            DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Void3")).Call(new object[] { 1, 2, 3 });
            target.Received().Void3(1, 2, 3);

            DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Void4")).Call(new object[] { 1, 2, 3, 4 });
            target.Received().Void4(1, 2, 3, 4);

            DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Void5")).Call(new object[] { 1, 2, 3, 4, 5 });
            target.Received().Void5(1, 2, 3, 4, 5);

            DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Void6")).Call(new object[] { 1, 2, 3, 4, 5, 6 });
            target.Received().Void6(1, 2, 3, 4, 5, 6);

            DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Void7")).Call(new object[] { 1, 2, 3, 4, 5, 6, 7 });
            target.Received().Void7(1, 2, 3, 4, 5, 6, 7);

            DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Void8")).Call(new object[] { 1, 2, 3, 4, 5, 6, 7, 8 });
            target.Received().Void8(1, 2, 3, 4, 5, 6, 7, 8);

            DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Void9")).Call(new object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 });
            target.Received().Void9(1, 2, 3, 4, 5, 6, 7, 8, 9);

            DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Void10")).Call(new object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
            target.Received().Void10(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
        }
Ejemplo n.º 18
0
        public void can_invoke_all_returning_overloads()
        {
            var targetType = typeof(ITarget);
            var target     = Substitute.For <ITarget>();

            DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Returns")).Call(new object[0]);
            target.Received().Returns();

            DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Returns1")).Call(new object[] { 1 });
            target.Received().Returns1(1);

            DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Returns2")).Call(new object[] { 1, 2 });
            target.Received().Returns2(1, 2);

            DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Returns3")).Call(new object[] { 1, 2, 3 });
            target.Received().Returns3(1, 2, 3);

            DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Returns4")).Call(new object[] { 1, 2, 3, 4 });
            target.Received().Returns4(1, 2, 3, 4);

            DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Returns5")).Call(new object[] { 1, 2, 3, 4, 5 });
            target.Received().Returns5(1, 2, 3, 4, 5);

            DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Returns6")).Call(new object[] { 1, 2, 3, 4, 5, 6 });
            target.Received().Returns6(1, 2, 3, 4, 5, 6);

            DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Returns7")).Call(new object[] { 1, 2, 3, 4, 5, 6, 7 });
            target.Received().Returns7(1, 2, 3, 4, 5, 6, 7);

            DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Returns8")).Call(new object[] { 1, 2, 3, 4, 5, 6, 7, 8 });
            target.Received().Returns8(1, 2, 3, 4, 5, 6, 7, 8);

            DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Returns9")).Call(new object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 });
            target.Received().Returns9(1, 2, 3, 4, 5, 6, 7, 8, 9);

            DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Returns10")).Call(new object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
            target.Received().Returns10(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
        }
Ejemplo n.º 19
0
        public void can_invoke_all_void_overloads_that_throw_exceptions()
        {
            var targetType = typeof(ITarget);
            var target     = Substitute.For <ITarget>();

            target.When(t => t.Void()).Do(c => { throw new ArgumentException(); });
            Assert.Throws <ArgumentException>(() => DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Void")).Call(new object[0]));

            target.When(t => t.Void1(1)).Do(c => { throw new ArgumentException(); });
            Assert.Throws <ArgumentException>(() => DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Void1")).Call(new object[] { 1 }));

            target.When(t => t.Void2(1, 2)).Do(c => { throw new ArgumentException(); });
            Assert.Throws <ArgumentException>(() => DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Void2")).Call(new object[] { 1, 2 }));

            target.When(t => t.Void3(1, 2, 3)).Do(c => { throw new ArgumentException(); });
            Assert.Throws <ArgumentException>(() => DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Void3")).Call(new object[] { 1, 2, 3 }));

            target.When(t => t.Void4(1, 2, 3, 4)).Do(c => { throw new ArgumentException(); });
            Assert.Throws <ArgumentException>(() => DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Void4")).Call(new object[] { 1, 2, 3, 4 }));

            target.When(t => t.Void5(1, 2, 3, 4, 5)).Do(c => { throw new ArgumentException(); });
            Assert.Throws <ArgumentException>(() => DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Void5")).Call(new object[] { 1, 2, 3, 4, 5 }));

            target.When(t => t.Void6(1, 2, 3, 4, 5, 6)).Do(c => { throw new ArgumentException(); });
            Assert.Throws <ArgumentException>(() => DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Void6")).Call(new object[] { 1, 2, 3, 4, 5, 6 }));

            target.When(t => t.Void7(1, 2, 3, 4, 5, 6, 7)).Do(c => { throw new ArgumentException(); });
            Assert.Throws <ArgumentException>(() => DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Void7")).Call(new object[] { 1, 2, 3, 4, 5, 6, 7 }));

            target.When(t => t.Void8(1, 2, 3, 4, 5, 6, 7, 8)).Do(c => { throw new ArgumentException(); });
            Assert.Throws <ArgumentException>(() => DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Void8")).Call(new object[] { 1, 2, 3, 4, 5, 6, 7, 8 }));

            target.When(t => t.Void9(1, 2, 3, 4, 5, 6, 7, 8, 9)).Do(c => { throw new ArgumentException(); });
            Assert.Throws <ArgumentException>(() => DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Void9")).Call(new object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }));

            target.When(t => t.Void10(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)).Do(c => { throw new ArgumentException(); });
            Assert.Throws <ArgumentException>(() => DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Void10")).Call(new object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }));
        }
Ejemplo n.º 20
0
        public void can_invoke_all_returning_overloads_that_throw_exceptions()
        {
            var targetType = typeof(ITarget);
            var target     = Substitute.For <ITarget>();

            target.When(t => t.Returns()).Do(c => { throw new ArgumentException(); });
            Assert.Throws <ArgumentException>(() => DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Returns")).Call(new object[0]));

            target.When(t => t.Returns1(1)).Do(c => { throw new ArgumentException(); });
            Assert.Throws <ArgumentException>(() => DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Returns1")).Call(new object[] { 1 }));

            target.When(t => t.Returns2(1, 2)).Do(c => { throw new ArgumentException(); });
            Assert.Throws <ArgumentException>(() => DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Returns2")).Call(new object[] { 1, 2 }));

            target.When(t => t.Returns3(1, 2, 3)).Do(c => { throw new ArgumentException(); });
            Assert.Throws <ArgumentException>(() => DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Returns3")).Call(new object[] { 1, 2, 3 }));

            target.When(t => t.Returns4(1, 2, 3, 4)).Do(c => { throw new ArgumentException(); });
            Assert.Throws <ArgumentException>(() => DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Returns4")).Call(new object[] { 1, 2, 3, 4 }));

            target.When(t => t.Returns5(1, 2, 3, 4, 5)).Do(c => { throw new ArgumentException(); });
            Assert.Throws <ArgumentException>(() => DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Returns5")).Call(new object[] { 1, 2, 3, 4, 5 }));

            target.When(t => t.Returns6(1, 2, 3, 4, 5, 6)).Do(c => { throw new ArgumentException(); });
            Assert.Throws <ArgumentException>(() => DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Returns6")).Call(new object[] { 1, 2, 3, 4, 5, 6 }));

            target.When(t => t.Returns7(1, 2, 3, 4, 5, 6, 7)).Do(c => { throw new ArgumentException(); });
            Assert.Throws <ArgumentException>(() => DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Returns7")).Call(new object[] { 1, 2, 3, 4, 5, 6, 7 }));

            target.When(t => t.Returns8(1, 2, 3, 4, 5, 6, 7, 8)).Do(c => { throw new ArgumentException(); });
            Assert.Throws <ArgumentException>(() => DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Returns8")).Call(new object[] { 1, 2, 3, 4, 5, 6, 7, 8 }));

            target.When(t => t.Returns9(1, 2, 3, 4, 5, 6, 7, 8, 9)).Do(c => { throw new ArgumentException(); });
            Assert.Throws <ArgumentException>(() => DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Returns9")).Call(new object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }));

            target.When(t => t.Returns10(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)).Do(c => { throw new ArgumentException(); });
            Assert.Throws <ArgumentException>(() => DelegateInvoker.CreateInvoker(target, targetType.GetMethod("Returns10")).Call(new object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }));
        }
Ejemplo n.º 21
0
        private void MultipleBindingTest(Mock <IParentInterface> mock)
        {
            _counter1 = 0;
            _counter2 = 0;

            DelegateInvoker invoker = mock.Expects.Exactly(2).DelegateBinding(_ => _.Delegate += null);

            mock.MockObject.Delegate += ListenerCounter1;
            mock.MockObject.Delegate += ListenerCounter2;

            invoker.Invoke("first");
            Assert.AreEqual("first", _message);

            mock.Expects.One.DelegateBinding(_ => _.Delegate -= null);

            mock.MockObject.Delegate -= ListenerCounter1;

            invoker.Invoke("second");

            Assert.AreEqual("second", _message);
            Assert.AreEqual(1, _counter1);
            Assert.AreEqual(2, _counter2);
        }
        /// <summary>
        /// Executes the action on the controller using the parameters and model binders in the current request.
        /// </summary>
        /// <param name="controllerContext">The controller context.</param>
        /// <param name="modelBinders">The model binders.</param>
        /// <returns>
        /// The <see cref="ActionResult"/> returned by the controller action.
        /// </returns>
        public ActionResult Execute(ControllerContext controllerContext, ModelBinderDictionary modelBinders)
        {
            var arguments = new List <object>();

            foreach (var parameterInfo in method.GetParameters())
            {
                var bindingContext = new ModelBindingContext(parameterInfo.Name, Method, parameterInfo.ParameterType, controllerContext.Request.RouteValues);
                var binder         = modelBinders.GetBinder(parameterInfo.ParameterType);
                var argument       = binder.BindModel(controllerContext.Request, bindingContext);
                arguments.Add(argument);
            }

            try
            {
                var wrapper = DelegateInvoker.CreateInvoker(controller, method);
                return((ActionResult)wrapper.Call(arguments.ToArray()));
            }
            catch (Exception ex)
            {
                TraceSources.MagellanSource.TraceError(ex, "The action '{0}' on controller '{1} threw an exception.", controllerContext.ActionName, controllerContext.ActionName);
                throw;
            }
        }
 private void CreateInvoker()
 {
     // lazy load in a way
     if (_targetType != null)
     {
         lock (_lock)
         {
             if (_activators.ContainsKey(_targetType))
             {
                 _invoker = _activators[_targetType](_method);
             }
             else
             {
                 var _func = CreateActivator();
                 _activators.Add(_targetType, _func);
                 _invoker = _func(_method);
             }
         }
     }
     else
     {
         _invoker = new DelegateInvoker <E>(_method);
     }
 }
Ejemplo n.º 24
0
 protected virtual void OnInsertText(string text)
 {
     DelegateInvoker.Invoke(InsertText, this, text);
 }
Ejemplo n.º 25
0
    /// <summary>
    /// </summary>
    /// <param name="objectMapperManager">The object mapper manager.</param>
    /// <param name="typeFrom">The type from.</param>
    /// <param name="typeTo">The type to.</param>
    /// <param name="mappingConfigurator">The mapping configurator.</param>
    /// <param name="storedObjects">The stored objects.</param>
    internal void Initialize(
        Mapper objectMapperManager,
        Type typeFrom,
        Type typeTo,
        IMappingConfigurator mappingConfigurator,
        object[] storedObjects)
    {
        Mapper              = objectMapperManager;
        TypeFrom            = typeFrom;
        TypeTo              = typeTo;
        MappingConfigurator = mappingConfigurator;
        StoredObjects       = storedObjects;

        if (MappingConfigurator != null)
        {
            RootOperation = MappingConfigurator.GetRootMappingOperation(typeFrom, typeTo)
                            ?? new RootMappingOperation(typeFrom, typeTo);

            var constructor = RootOperation.TargetConstructor;

            if (constructor != null)
            {
                TargetConstructor = (DelegateInvokerFunc0)DelegateInvoker.GetDelegateInvoker(constructor);
            }

            var valuesPostProcessor = RootOperation.ValuesPostProcessor;

            if (valuesPostProcessor != null)
            {
                ValuesPostProcessor = (DelegateInvokerFunc2)DelegateInvoker.GetDelegateInvoker(valuesPostProcessor);
            }

            var converter = RootOperation.Converter;

            if (converter != null)
            {
                Converter = (DelegateInvokerFunc2)DelegateInvoker.GetDelegateInvoker(converter);
            }

            var nullSubstitutor = RootOperation.NullSubstitutor;

            if (nullSubstitutor != null)
            {
                NullSubstitutor = (DelegateInvokerFunc0)DelegateInvoker.GetDelegateInvoker(nullSubstitutor);
            }

            var sourceFilter = RootOperation.SourceFilter;

            if (sourceFilter != null)
            {
                SourceFilter = (DelegateInvokerFunc2)DelegateInvoker.GetDelegateInvoker(sourceFilter);
            }

            var destinationFilter = RootOperation.DestinationFilter;

            if (destinationFilter != null)
            {
                DestinationFilter = (DelegateInvokerFunc2)DelegateInvoker.GetDelegateInvoker(destinationFilter);
            }
        }
    }
Ejemplo n.º 26
0
 internal void Queue(DelegateInvoker delegateInvoker)
 {
     lock (_eventQueueLock)
     {
         _eventQueue.Enqueue(delegateInvoker);
         Monitor.Pulse(_eventQueueLock);
     }
 }
Ejemplo n.º 27
0
 public bool Equals(DelegateInvoker <T> other) => Handler.GetHashCode() == other.Handler.GetHashCode();
Ejemplo n.º 28
0
 internal void Queue(DelegateInvoker delegateInvoker)
 {
     ThreadPool.QueueUserWorkItem(state =>
     {
         try
         {
             delegateInvoker.Execute();
         }
         catch (Exception ex)
         {
             OnException(new SessionEventArgs(ex.ToString()));
         }
     });
 }