Ejemplo n.º 1
0
        private void ExecuteNextCommand()
        {
            if (_injector.HasMapping <Action <IAsyncCommand, bool> >(AsyncCommandExecutedCallbackName))
            {
                _injector.Unmap <Action <IAsyncCommand, bool> >(AsyncCommandExecutedCallbackName);
            }

            while (!IsAborted && _commandMappingQueue.Count > 0)
            {
                ICommandMapping mapping = _commandMappingQueue.Dequeue();

                if (mapping != null)
                {
                    _injector.Map <Action <IAsyncCommand, bool> >(AsyncCommandExecutedCallbackName).ToValue((Action <IAsyncCommand, bool>)CommandExecutedCallback);
                    _commandExecutor.ExecuteCommand(mapping, _payload);
                    return;
                }
            }

            if (IsAborted)
            {
                _commandMappingQueue.Clear();
                _commandsAbortedCallback?.Invoke();
            }
            else if (_commandMappingQueue.Count == 0)
            {
                _commandsExecutedCallback?.Invoke();
            }
        }
Ejemplo n.º 2
0
        /*============================================================================*/
        /* Constructor                                                                */
        /*============================================================================*/

        public MediatorFactory(IInjector injector)
        {
            _injector = injector;
            _manager  = injector.HasMapping(typeof(IMediatorManager))
                                ? injector.GetInstance(typeof(IMediatorManager)) as IMediatorManager
                                : new MediatorManager();
            _manager.ViewRemoved += RemoveMediators;
        }
		/*============================================================================*/
		/* Constructor                                                                */
		/*============================================================================*/

		public MediatorFactory (IInjector injector)
		{
			_injector = injector;
			_manager = injector.HasMapping (typeof(IMediatorManager)) 
				? injector.GetInstance (typeof(IMediatorManager)) as IMediatorManager
				: new MediatorManager ();
			_manager.ViewRemoved += RemoveMediators;
		}
 private ModuleConnectionConfigurator CreateConfigurator(object channelId)
 {
     if (!_rootInjector.HasMapping(typeof(IEventDispatcher), channelId))
     {
         _rootInjector.Map(typeof(IEventDispatcher), channelId)
         .ToValue(new EventDispatcher());
     }
     return(new ModuleConnectionConfigurator(_localDispatcher, _rootInjector.GetInstance(typeof(IEventDispatcher), channelId) as IEventDispatcher));
 }
Ejemplo n.º 5
0
        private object CreateProcessor(Type processorClass)
        {
            if (!_injector.HasMapping(processorClass))
            {
                _injector.Map(processorClass).AsSingleton();
            }

            try
            {
                return(_injector.GetInstance(processorClass));
            }
            catch (InjectorInterfaceConstructionException exception)
            {
                String errorMsg = "The view processor "
                                  + processorClass.ToString()
                                  + " has not been mapped in the injector, "
                                  + "and it is not possible to instantiate an interface. "
                                  + "Please map a concrete type against this interface."
                                  + "Triggered from InjectorInterfaceConstructionException."
                                  + exception.Message;
                throw(new ViewProcessorMapException(errorMsg));
            }
        }
 public void Does_Not_Leave_View_Mapping_Lying_Around()
 {
     viewProcessorMap.Map(matchingView.GetType()).ToProcess(trackingProcessor);
     viewProcessorMap.HandleView(matchingView, matchingView.GetType());
     Assert.That(injector.HasMapping(matchingView.GetType()), Is.False);
 }