Exemplo n.º 1
0
 //////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Sends event synchronously
 /// </summary>
 public void SendEvent(IEventDispatcher dispatcher)
 {
     using (dispatcher)
     {
         dispatcher.Dispatch();
     }
 }
Exemplo n.º 2
0
        public void UnPack(Client client, Packet packet, IEventDispatcher eventDispatcher)
        {
            string name = packet.Reader.ReadString();
            string modeltype = packet.Reader.ReadString();

            eventDispatcher.ThrowNewEvent(EventID, new PlayerBasicsDatas(name, modeltype, client));
        }
Exemplo n.º 3
0
 public RuntimeEntity(int uniqueId, ITemplate template, IEventDispatcher eventDispatcher)
     : this(uniqueId, eventDispatcher, "") {
     foreach (DataAccessor accessor in template.SelectData()) {
         Data.IData data = template.Current(accessor);
         AddData_unlocked(accessor, data.Duplicate());
     }
 }
		/*============================================================================*/
		/* Public Functions                                                           */
		/*============================================================================*/

		public void MapListener(IEventDispatcher dispatcher, Enum type, Delegate listener, Type eventClass = null)
		{
			if (eventClass == null)
			{	
				eventClass = typeof(Event);
			}

			List<EventMapConfig> currentListeners = _suspended ? _suspendedListeners : _listeners;

			EventMapConfig config;

			int i = currentListeners.Count;

			while (i-- > 0) 
			{
				config = currentListeners [i];
				if (config.Equals (dispatcher, type, listener, eventClass))
					return;
			}

			Delegate callback = eventClass == typeof(Event) ? listener : (Action<IEvent>)delegate(IEvent evt){
				RouteEventToListener(evt, listener, eventClass);
			};

			config = new EventMapConfig (dispatcher, type, listener, eventClass, callback);

			currentListeners.Add (config);

			if (!_suspended) 
			{
				dispatcher.AddEventListener (type, callback);
			}
		}
Exemplo n.º 5
0
 static LogManager()
 {
     _configuration = PulsusConfiguration.Default;
     _eventsFactory = new DefaultEventFactory();
     _eventDispatcher = new DefaultEventDispatcher(_configuration);
     _jsonSerializer = new JsonNetSerializer();
 }
		/*============================================================================*/
		/* Constructor                                                                */
		/*============================================================================*/

		public ModuleConnectionConfigurator(
			IEventDispatcher localDispatcher,
			IEventDispatcher channelDispatcher)
		{
			_localToChannelRelay = new EventRelay(localDispatcher, channelDispatcher).Start();
			_channelToLocalRelay = new EventRelay(channelDispatcher, localDispatcher).Start();
		}
Exemplo n.º 7
0
        public void RegisterAbility(NWCard parentCard, IEventDispatcher eventDispatcher, AbilityActivatedDelegate activatedCallBack)
        {
            _parentCard = parentCard;
            if (Type == NWAbilityType.Triggered)
            {
                switch (Trigger.Type)
                {
                case NWTriggerType.DrawCard:
                {
                    break;
                }
                case NWTriggerType.EnterZone:
                {
                    eventDispatcher.OnCardChangeZone += CardChangeZoneHandler;
                    break;
                }
                case NWTriggerType.StartOfTurn:
                {
                    break;
                }
                case NWTriggerType.None:
                default:
                {
                    break;
                }
                }

                OnActivateAbility += activatedCallBack;
            }
        }
		public void UnmapListener(IEventDispatcher dispatcher, Enum type, Delegate listener, Type eventClass = null)
		{
			if (eventClass == null)
			{	
				eventClass = typeof(Event);
			}

			List<EventMapConfig> currentListeners = _suspended ? _suspendedListeners : _listeners;

			EventMapConfig config;

			int i = currentListeners.Count;

			while (i-- > 0) 
			{
				config = currentListeners [i];
				if (config.Equals (dispatcher, type, listener, eventClass)) 
				{
					if (!_suspended) 
					{
						dispatcher.RemoveEventListener (type, config.callback);
					}
					currentListeners.RemoveAt (i);
					return;
				}
			}
		}
Exemplo n.º 9
0
        public static void AddListener(int type, IEventListener listener, IEventDispatcher source = null)
        {
            if (!listeners.ContainsKey(type))
                listeners.Add(type, new List<ListenerData>());

            listeners[type].Add(new ListenerData(listener, source));
        }
Exemplo n.º 10
0
        public void UnPack(Client client, Packet packet, IEventDispatcher eventDispatcher)
        {
            byte id = packet.Reader.ReadByte();
            float x = packet.Reader.ReadSingle(), y = packet.Reader.ReadSingle(), d= packet.Reader.ReadSingle();

            eventDispatcher.ThrowNewEvent(EventID, new GiveImpulseDatas {ID = id, X = x, Y = y, Damages = d});
        }
Exemplo n.º 11
0
 public bool Init(IEventDispatcher disp)
 {
     _disp = disp;
     //给创建完成Timer事件注册一个方法
     _window.EventCreateTimer += WindowOnEventCreateTimer;
     return true;
 }
Exemplo n.º 12
0
        public void UnPack(Client client, Packet packet, IEventDispatcher eventDispatcher)
        {
            byte id = packet.Reader.ReadByte(), anim = packet.Reader.ReadByte(), lives = packet.Reader.ReadByte();
            float x = packet.Reader.ReadSingle(), y = packet.Reader.ReadSingle(), yaw = packet.Reader.ReadSingle(), damages = packet.Reader.ReadSingle();

            eventDispatcher.ThrowNewEvent(EventID, new CharacterPositionDatas { ID = id, X = x, Y = y, Yaw = yaw, Anim = anim, Lives = lives, Damages = damages});
        }
 /// <summary>
 /// Init constructor.
 /// </summary>
 public RecordedBayeuxDataSource(IEventDispatcher eventDispatcher, string url, string contentType, bool allowUpdateToken)
     : base(eventDispatcher, url, contentType)
 {
     Token = DefaultToken;
     ClientID = "0xDEADBEEF";
     AllowUpdateTokenOnRequest = allowUpdateToken;
 }
		public void before()
		{
			context = new Context();
			dispatcher = new EventDispatcher();
			subject = new LifecycleEventRelay(context, dispatcher);
			reportedTypes = new List<object>();
		}
Exemplo n.º 15
0
 public Event(string type, bool bubbles = false)
 {
     this.Type = type;
     this._isBubbles = bubbles;
     target = null;
     currentTarget = null;
 }
Exemplo n.º 16
0
        public void UnPack(Client client, Packet packet, IEventDispatcher eventDispatcher)
        {
            string ip = client.ToString().Split(':')[0];
            ushort port = packet.Reader.ReadUInt16();

            eventDispatcher.ThrowNewEvent(EventID, new MasterServerDatas {IP = ip, Port = port});
        }
		/*============================================================================*/
		/* Constructor                                                                */
		/*============================================================================*/

		/**
		 * @private
		 */
		public ModuleConnector(IContext context)
		{
			IInjector injector= context.injector;
			_rootInjector = GetRootInjector(injector);
			_localDispatcher = injector.GetInstance(typeof(IEventDispatcher)) as IEventDispatcher;
			context.WhenDestroying(Destroy);
		}
Exemplo n.º 18
0
 public EventProcessor(IEventStoreConnectionFactory eventStoreConnectionFactory, IEventDispatcher eventDispatcher,
     IMongoDbEventPositionRepository mongoDbEventPositionRepository, ILog logService)
 {
     this.eventStoreConnectionFactory = eventStoreConnectionFactory;
     this.eventDispatcher = eventDispatcher;
     this.mongoDbEventPositionRepository = mongoDbEventPositionRepository;
     this.logService = logService;
 }
		/*============================================================================*/
		/* Constructor                                                                */
		/*============================================================================*/

		public EventMapConfig (IEventDispatcher dispatcher, Enum type, Delegate listener, Type eventClass, Delegate callback)
		{
			_dispatcher = dispatcher;
			_type = type;
			_eventClass = eventClass;
			_listener = listener;
			_callback = callback;
		}
		/*============================================================================*/
		/* Constructor                                                                */
		/*============================================================================*/

		public EventCommandTrigger (IInjector injector, IEventDispatcher dispatcher, Enum type, Type eventClass = null, IEnumerable<CommandMappingList.Processor> processors = null, ILogger logger = null)
		{
			_dispatcher = dispatcher;
			_type = type;
			_eventClass = eventClass;
			_mappings = new CommandMappingList(this, processors, logger);
			_executor = new CommandExecutor(injector, _mappings.RemoveMapping);
		}
 //---------------------------------------------------------------------
 //  Constructor
 //---------------------------------------------------------------------
 /**
  * Creates a new <code>CommandMap</code> object
  *
  * @param eventDispatcher The <code>IEventDispatcher</code> to listen to
  * @param injector An <code>IInjector</code> to use for this context
  * @param reflector An <code>IReflector</code> to use for this context
  */
 public CommandMap( IEventDispatcher eventDispatcher, IInjector injector, IReflector reflector )
 {
     this.eventDispatcher = eventDispatcher;
     this.injector = injector;
     this.reflector = reflector;
     this.eventTypeMap = new Dictionary<string,Dictionary<Type, Dictionary<Type, Action<Event>>>>();
     this.verifiedCommandClasses = new Dictionary<Type,bool>();
 }
        public PrnGenerationIntegration()
        {
            userContext = A.Fake<IUserContext>();

            A.CallTo(() => userContext.UserId).Returns(Guid.NewGuid());

            eventDispatcher = A.Fake<IEventDispatcher>();
        }
		/*============================================================================*/
		/* Constructor                                                                */
		/*============================================================================*/

		public ContextViewBasedExistenceWatcher(IContext context, object contextView, IEventDispatcher modularityDispatcher, IParentFinder parentFinder)
		{
			_logger = context.GetLogger(this);
			_context = context;
			_contextView = contextView;
			_parentFinder = parentFinder;
			_modularityDispatcher = modularityDispatcher;
			_context.WhenDestroying(Destroy);
		}
		public void before()
		{
			reportedExecutions = new List<object>();
			IContext context = new Context();
			injector = context.injector;
			injector.Map(typeof(Action<object>), "ReportingFunction").ToValue((Action<object>)reportingFunction);
			dispatcher = new EventDispatcher();
			subject = new EventCommandMap(context, dispatcher);
		}
Exemplo n.º 25
0
        public CommandDispatcher(
			ICommandHandler[] handlers,
			Func<IEnumerable<ICommandHandler>> pluginHandlerFactory,
			IEventDispatcher eventDispatcher)
        {
            _handlers = handlers;
            _pluginHandlerFactory = pluginHandlerFactory;
            _eventDispatcher = eventDispatcher;
        }
 public void SetUp() {
     dataLayerMock = MockRepository.StrictMock<IDataLayer>();
     settingsStub = MockRepository.Stub<ISettings>();
     eventDispatcherMock = MockRepository.StrictMock<IEventDispatcher>();
     viewMock = MockRepository.StrictMock<IOptionsPageView>();
     loggerFactoryMock = MockRepository.DynamicMock<ILoggerFactory>();
     loggerFactoryMock.Stub(x => x.GetLogger(null)).IgnoreArguments().Return(MockRepository.Stub<ILogger>());
     controller = new OptionsPageController(loggerFactoryMock, dataLayerMock, settingsStub, eventDispatcherMock);
 }
        public WasteRecoveryIntegration()
        {
            var userContext = A.Fake<IUserContext>();

            A.CallTo(() => userContext.UserId).Returns(Guid.NewGuid());

            eventDispatcher = A.Fake<IEventDispatcher>();

            context = new IwsContext(userContext, eventDispatcher);
        }
Exemplo n.º 28
0
        public static void RemoveListener(int type, IEventListener listener, IEventDispatcher source = null)
        {
            if (listeners.ContainsKey(type))
            foreach (var l in listeners[type].FindAll(x => ReferenceEquals(x.Listener, listener)))
                if ((l.DSource == null && source == null) || ReferenceEquals(l.DSource, source))
                    listeners[type].Remove(l);

            if (listeners[type].Count == 0)
                listeners.Remove(type);
        }
Exemplo n.º 29
0
 public void Parse(Client client, Packet.Packet packet, IEventDispatcher eventDispatcher)
 {
     if (!_packets.ContainsKey(packet.Header.ID))
     {
         if (PacketNotFound != null)
             PacketNotFound.BeginInvoke(packet, null, null);
     }
     else
         _packets[packet.Header.ID].UnPack(client, packet, eventDispatcher);
 }
        public void RunBeforeEachTest()
        {
            eventDispatcher = new EventDispatcher();
            injector = new UnityInjector();
            reflector = new UnityReflector();
            commandMap = new CommandMap( eventDispatcher, injector, reflector );

            //TODO Use the Unity lifetimemanager here
            injector.MapValue( typeof(ICommandTest), this  );
        }
        public RuntimeEntityService(IEventDispatcher eventDispatcher,
                                    ILogger logger, [CanBeNull] IEntityTemplateProvider templateProvider = null,
                                    [CanBeNull] ICollection <EngineEntity> entities = null)
        {
            _eventDispatcher = eventDispatcher;
            _logger          = logger;
            TemplateProvider = templateProvider;

            if (entities != null)
            {
                foreach (var entity in entities)
                {
                    _entityList.Add(entity);
                    _entityLookup.Add(entity.Id, entity);
                }
            }

            _idProvider = new UniqueIdProvider(_entityList.Count > 0 ? _entityList.Max(p => p.Id + 1) : 0);
        }
Exemplo n.º 32
0
        public CommandProcessor(
            IEventStore eventStore, IAggregateRootRepository aggregateRootRepository, IEventDispatcher eventDispatcher,
            IDomainEventSerializer domainEventSerializer, ICommandMapper commandMapper, IDomainTypeNameMapper domainTypeNameMapper,
            Options options)
        {
            if (eventStore == null)
            {
                throw new ArgumentNullException("eventStore");
            }
            if (aggregateRootRepository == null)
            {
                throw new ArgumentNullException("aggregateRootRepository");
            }
            if (eventDispatcher == null)
            {
                throw new ArgumentNullException("eventDispatcher");
            }
            if (domainEventSerializer == null)
            {
                throw new ArgumentNullException("domainEventSerializer");
            }
            if (commandMapper == null)
            {
                throw new ArgumentNullException("commandMapper");
            }
            if (domainTypeNameMapper == null)
            {
                throw new ArgumentNullException("domainTypeNameMapper");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            _eventStore = eventStore;
            _aggregateRootRepository = aggregateRootRepository;
            _eventDispatcher         = eventDispatcher;
            _domainEventSerializer   = domainEventSerializer;
            _commandMapper           = commandMapper;
            _domainTypeNameMapper    = domainTypeNameMapper;
            _options = options;
        }
Exemplo n.º 33
0
        public PowerLogEventStream(
            IConfigurationSource configurationSource,
            IPowerLogEventParser powerLogEventParser,
            IEventDispatcher viewEventDispatcher,
            bool seekEndWhenFileChanges)
        {
            _configurationSource = configurationSource.Require(nameof(configurationSource));
            _powerLogEventParser = powerLogEventParser.Require(nameof(powerLogEventParser));
            _viewEventDispatcher = viewEventDispatcher.Require(nameof(viewEventDispatcher));

            _seekEndWhenFileChanges = seekEndWhenFileChanges;

            _filePath = _configurationSource.GetSettings().PowerLogFilePath;

            _eventHandlers.Add(
                new DelegateEventHandler <ViewEvents.ConfigurationSettingsSaved>(
                    __event =>
            {
                string newFilePath = _configurationSource.GetSettings().PowerLogFilePath;
                if (!newFilePath.Eq(_filePath))
                {
                    Task.Run(
                        () =>
                    {
                        lock (_lock)
                        {
                            _remainingText  = null;
                            _streamPosition = 0L;

                            _filePath = newFilePath;

                            if (_seekEndWhenFileChanges)
                            {
                                SeekEnd_();
                            }
                        }
                    });
                }
            }));

            _eventHandlers.ForEach(__eventHandler => _viewEventDispatcher.RegisterHandler(__eventHandler));
        }
Exemplo n.º 34
0
        /**
         * @private
         */
        internal void _init(
            ArmatureData armatureData, SkinData skinData,
            object display, IArmatureProxy proxy, IEventDispatcher <EventObject> eventManager
            )
        {
            if (_armatureData != null)
            {
                return;
            }

            _armatureData = armatureData;
            _skinData     = skinData;
            _animation    = BaseObject.BorrowObject <Animation>();
            _display      = display;
            _proxy        = proxy;
            _eventManager = eventManager;

            _animation._init(this);
            _animation.animations = _armatureData.animations;
        }
Exemplo n.º 35
0
 public WaitEvent(IEventDispatcher dispatcher, string EventType, object thisObj, string callName, object[] paramList = null, bool checkSame = true)
 {
     if (checkSame)
     {
         for (int i = 0; i < list.Count; i++)
         {
             if (list[i].dispatcher == dispatcher && list[i].EventType == EventType && list[i].thisObj == thisObj && list[i].callName == callName)
             {
                 return;
             }
         }
     }
     this.dispatcher = dispatcher;
     this.EventType  = EventType;
     this.thisObj    = thisObj;
     this.callName   = callName;
     this.paramList  = paramList;
     dispatcher.AddListener(EventType, OnListenerBack);
     list.Add(this);
 }
Exemplo n.º 36
0
 public GarbageCollectionSegmentRunner(
     IContext context,
     IParameterProvider parameterProvider,
     IOperationExecutive operationExecutive,
     IGateway <TEntity> gateway,
     ISafeRepository safeRepository,
     IEventDispatcher <TEntity> eventDispatcher,
     IInitializer initializer)
 {
     this.context               = context;
     this.parameterProvider     = parameterProvider;
     this.operationExecutive    = operationExecutive;
     this.gateway               = gateway;
     this.safeRepository        = safeRepository;
     this.eventDispatcher       = eventDispatcher;
     this.idsOfEntitiesToDelete = null;
     initializer.Register(
         new Initializer(this),
         suppressEvents: true);
 }
Exemplo n.º 37
0
    /// Returns true if the provided observer is already registered
    public static bool HasListenerStrangeEvent(object evt, EventCallback callback)
    {
        if (strangeDispatcher == null && instance != null && instance.context != null)
        {
            if ((instance.context as MainContextInput).dispatcher != null)
            {
                strangeDispatcher = (instance.context as MainContextInput).dispatcher;
            }
        }

        if (strangeDispatcher != null)
        {
            return(strangeDispatcher.HasListener(evt, callback));
        }
        else
        {
            Debug.LogError("strangeDispatcher Not Redy");
        }
        return(false);
    }
Exemplo n.º 38
0
        /**
         * @private
         */
        override protected Armature _generateArmature(BuildArmaturePackage dataPackage)
        {
            if (Application.isPlaying)
            {
                if (_gameObject == null)
                {
                    _gameObject           = new GameObject("DragonBones Object", typeof(ClockHandler));
                    _gameObject.isStatic  = true;
                    _gameObject.hideFlags = HideFlags.HideInHierarchy;
                }

                if (_eventManager == null)
                {
                    _eventManager = _gameObject.AddComponent <UnityArmatureComponent>();
                }
            }

            var armature = BaseObject.BorrowObject <Armature>();
            var armatureDisplayContainer = _armatureGameObject == null ? new GameObject(dataPackage.armature.name) : _armatureGameObject;
            var armatureComponent        = armatureDisplayContainer.GetComponent <UnityArmatureComponent>();

            if (armatureComponent == null)
            {
                armatureComponent = armatureDisplayContainer.AddComponent <UnityArmatureComponent>();
            }

            armatureComponent._armature = armature;

            armature._armatureData        = dataPackage.armature;
            armature._skinData            = dataPackage.skin;
            armature._animation           = BaseObject.BorrowObject <Animation>();
            armature._display             = armatureDisplayContainer;
            armature._eventDispatcher     = armatureComponent;
            armature._eventManager        = _eventManager;
            armature._animation._armature = armature;
            armature.animation.animations = dataPackage.armature.animations;

            _armatureGameObject = null;

            return(armature);
        }
        public void SetupBase()
        {
            _plantProviderMock = new Mock <IPlantProvider>();
            _plantProviderMock.SetupGet(x => x.Plant).Returns(TestPlant);
            _plantProvider = _plantProviderMock.Object;

            _personApiServiceMock = new Mock <IPersonApiService>();
            _personApiService     = _personApiServiceMock.Object;

            var currentUserProviderMock = new Mock <ICurrentUserProvider>();

            currentUserProviderMock.Setup(x => x.GetCurrentUserOid()).Returns(_currentUserOid);
            _currentUserProvider = currentUserProviderMock.Object;

            var eventDispatcher = new Mock <IEventDispatcher>();

            _eventDispatcher = eventDispatcher.Object;

            var permissionCacheMock = new Mock <IPermissionCache>();

            _permissionCache = permissionCacheMock.Object;

            _timeProvider = new ManualTimeProvider(new DateTime(2020, 2, 1, 0, 0, 0, DateTimeKind.Utc));
            TimeService.SetProvider(_timeProvider);

            _dbContextOptions = new DbContextOptionsBuilder <IPOContext>()
                                .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                .Options;

            // ensure current user exists in db
            using (var context = new IPOContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider))
            {
                if (context.Persons.SingleOrDefault(p => p.Oid == _currentUserOid) == null)
                {
                    var person = AddPerson(context, _currentUserOid, "Ole", "Lukkøye", "ol", "*****@*****.**");
                    AddSavedFiltersToPerson(context, person);
                }
            }

            SetupNewDatabase(_dbContextOptions);
        }
Exemplo n.º 40
0
        private void RedispatchKeyEvent(IEventDispatcher targetComponent, ICloneable systemManagerKeyEvent)
        {
            _keyEvent        = (KeyboardEvent)systemManagerKeyEvent.Clone();
            _keyEvent.Target = targetComponent;

            /**
             * 1) Dispatch from here
             * */
            DispatchEvent(_keyEvent);

            // the event might be canceled
            if (_keyEvent.Canceled)
            {
                return;
            }

            /**
             * 2) Dispatch from the component
             * */
            targetComponent.DispatchEvent(_keyEvent);
        }
Exemplo n.º 41
0
        protected async Task FinishProduction(IEventDispatcher eventDispatcher)
        {
            var productionFinished = false;

            eventDispatcher.RegisterHandler <ProductionFinishedEvent>(async e =>
            {
                productionFinished = true;
                await Task.Delay(0);
            });
            await Task.Run(async() =>
            {
                while (true)
                {
                    if (productionFinished)
                    {
                        break;
                    }
                    await Task.Delay(200);
                }
            });
        }
Exemplo n.º 42
0
        protected async Task HeatOven(IEventDispatcher eventDispatcher)
        {
            bool isOvenHeated = false;

            eventDispatcher.RegisterHandler <OvenHeatedEvent>(async e =>
            {
                isOvenHeated = true;
                await Task.Delay(0);
            });
            await Task.Run(async() =>
            {
                while (true)
                {
                    if (isOvenHeated)
                    {
                        break;
                    }
                    await Task.Delay(200);
                }
            });
        }
Exemplo n.º 43
0
        public void SetUp()
        {
            matchTileGridModel = Substitute.For <IMatchTileGridModel>();
            eventDispatcher    = Substitute.For <IEventDispatcher> ();

            matchTileTouchedCommand = new MatchTileTouchedCommand();
            matchTileTouchedCommand.matchTileGridModel = matchTileGridModel;
            matchTileTouchedCommand.eventDispatcher    = eventDispatcher;

            GameObject gameObject = new GameObject();

            gameObject.transform.localPosition = Vector3.zero;

            TouchedObject touchedObject = new TouchedObject();

            touchedObject.objectHit = gameObject;

            matchTileTouchedCommand.touchedObject = touchedObject;

            eventDispatcher.CleanAndDestroy();
        }
Exemplo n.º 44
0
 public void InjectDependencies(
     int heroInstanceId,
     ITurnHandler turnHandler,
     IEventDispatcher eventDispatcher,
     IGameActionsExecutioner gameActionsExecutioner)
 {
     InitializeHeroEntity(heroInstanceId);
     _turnHandler = turnHandler;
     _heroSelector.InjectDependencies(
         _hero,
         turnHandler,
         _heroActionController,
         eventDispatcher
         );
     _heroActionController.InjectDependencies(_hero, gameActionsExecutioner);
     _heroMovementController.InjectDependencies(_hero);
     _guiView.InjectDependencies(_hero, HeroHealth);
     _heroHealthController.InjectDependencies(_hero, HeroHealth);
     _heroAttackController.InjectDependencies(_hero);
     _heroAbilityController.InjectDependencies(_hero);
 }
Exemplo n.º 45
0
 public TransitionCommitter(
     ICommunicationModelProvider communicationModelProvider,
     IPlatformHttpClientProvider platformHttpClientProvider,
     IRoutineCompletionSink routineCompletionSink,
     IEventDispatcher eventDispatcher,
     IRoutineMethodResolver routineMethodResolver,
     IDomainServiceProvider domainServiceProvider,
     IMethodInvokerFactory methodInvokerFactory,
     IEnumerable <IRoutineTransitionAction> transitionActions,
     ITransitionUserContext transitionUserContext)
 {
     _communicationModelProvider = communicationModelProvider;
     _platformHttpClientProvider = platformHttpClientProvider;
     _routineCompletionSink      = routineCompletionSink;
     _eventDispatcher            = eventDispatcher;
     _routineMethodResolver      = routineMethodResolver;
     _domainServiceProvider      = domainServiceProvider;
     _methodInvokerFactory       = methodInvokerFactory;
     _transitionActions          = transitionActions;
     _transitionUserContext      = transitionUserContext;
 }
Exemplo n.º 46
0
        /// <summary>
        ///     Binds the lifetime of the pool to the <see cref="eventDispatcher" />.
        /// </summary>
        /// <param name="self"></param>
        /// <param name="eventDispatcher"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"></exception>
        public static AddressablesPool BindTo(this AddressablesPool self, IEventDispatcher eventDispatcher)
        {
            if (eventDispatcher == null)
            {
                self.Dispose();
                throw new ArgumentNullException(nameof(eventDispatcher));
            }

            void OnDispatch()
            {
                if (!self.IsDisposed)
                {
                    self.Dispose();
                }

                eventDispatcher.OnDispatch -= OnDispatch;
            }

            eventDispatcher.OnDispatch += OnDispatch;
            return(self);
        }
Exemplo n.º 47
0
        public SavedLogViewModel(
            IConfigurationSource configurationSource,
            IPowerLogManager powerLogManager,
            IEventDispatcher viewEventDispatcher,
            Guid id,
            string title,
            DateTimeOffset timestamp,
            string filePath)
        {
            configurationSource.Require(nameof(configurationSource));

            _powerLogManager     = powerLogManager.Require(nameof(powerLogManager));
            _viewEventDispatcher = viewEventDispatcher.Require(nameof(viewEventDispatcher));

            ID        = id;
            Title     = title ?? string.Empty;
            Timestamp = timestamp;
            _filePath = filePath;

            _textEditorFilePath = configurationSource.GetSettings().TextEditorFilePath;
        }
Exemplo n.º 48
0
    public Singleton(
        DiContainer container,
        GameStateMachine <JameStateType> gsMachine,
        SessionFlags pSessionFlags,
        [Inject(Id = GameInstaller.GLOBAL_DISPATCHER)]
        IEventDispatcher eventDispatcher,
        GameConfig pGameConfig,
        NetworkManager pNetworkManager,
        GuiManager guiManager)
    {
        diContainer            = container;
        sessionFlags           = pSessionFlags;
        gameConfig             = pGameConfig;
        gameStateMachine       = gsMachine;
        notificationDispatcher = eventDispatcher;
        networkManager         = pNetworkManager;
        gui = guiManager;

        _initialize();
        _instance = this;
    }
        public LocalDatabaseCardInfoProvider(
            ICardDatabase cardDatabase,
            IEventDispatcher eventDispatcher)
        {
            _cardDatabase    = cardDatabase.Require(nameof(cardDatabase));
            _eventDispatcher = eventDispatcher.Require(nameof(eventDispatcher));

            LoadCards();

            _eventDispatcher.RegisterHandler(
                new DelegateEventHandler <ViewEvents.CardDatabaseUpdated>(
                    __ => LoadCards()));

            void LoadCards()
            {
                IEnumerable <Models.Data.Card> cardInfos = _cardDatabase.GetCards().Result;

                _cardByDatabaseID = cardInfos.ToDictionary(__cardInfo => __cardInfo.dbfId);
                _cardByID         = cardInfos.ToDictionary(__cardInfo => __cardInfo.id);
            }
        }
Exemplo n.º 50
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EventDispatcher" /> class.
        /// </summary>
        /// <param name="eventDispatcher">The event dispatcher.</param>
        /// <param name="eventStore">The event store.</param>
        /// <param name="notificationService">The notification service.</param>
        /// <param name="dispatcherId">The dispatcher identifier.</param>
        /// <param name="batchSize">Size of the batch.</param>
        public EventDispatcher(
            IEventDispatcher eventDispatcher,
            IEventStore eventStore,
            INotificationService notificationService,
            Guid dispatcherId,
            int batchSize)
        {
            Guard.Against.Null(() => eventDispatcher);
            Guard.Against.Null(() => eventStore);
            Guard.Against.Null(() => notificationService);

            this.eventDispatcher     = eventDispatcher;
            this.eventStore          = eventStore;
            this.notificationService = notificationService;
            this.dispatcherId        = dispatcherId;
            this.batchSize           = batchSize;

            this.timer = new Timer(this.OnTimeout, null, Timeout.Infinite, Timeout.Infinite);

            this.Start();
        }
Exemplo n.º 51
0
        public TS3QueryClient(EventDispatchType dispatcher)
        {
            status    = QueryClientStatus.Disconnected;
            tcpClient = new TcpClient();
            isInQueue = false;

            switch (dispatcher)
            {
            case EventDispatchType.None: EventDispatcher = new NoEventDispatcher(); break;

            case EventDispatchType.CurrentThread: EventDispatcher = new CurrentThreadEventDisptcher(); break;

            case EventDispatchType.DoubleThread: EventDispatcher = new DoubleThreadEventDispatcher(); break;

            case EventDispatchType.AutoThreadPooled: throw new NotSupportedException();          //break;

            case EventDispatchType.NewThreadEach: throw new NotSupportedException();             //break;

            default: throw new NotSupportedException();
            }
        }
Exemplo n.º 52
0
        /**
         * @private
         */
        override protected Armature _generateArmature(BuildArmaturePackage dataPackage)
        {
            if (Application.isPlaying) //
            {
                if (_gameObject == null)
                {
                    _gameObject           = new GameObject("DragonBones Object", typeof(ClockHandler));
                    _gameObject.isStatic  = true;
                    _gameObject.hideFlags = HideFlags.HideInHierarchy;
                }

                if (_eventManager == null)
                {
                    _eventManager = _gameObject.AddComponent <UnityArmatureComponent>();
                    (_eventManager as UnityArmatureComponent).isUGUI = _isUGUI;
                }
            }

            var armature          = BaseObject.BorrowObject <Armature>();
            var armatureDisplay   = _armatureGameObject == null ? new GameObject(dataPackage.armature.name) : _armatureGameObject;
            var armatureComponent = armatureDisplay.GetComponent <UnityArmatureComponent>();

            if (armatureComponent == null)
            {
                armatureComponent        = armatureDisplay.AddComponent <UnityArmatureComponent>();
                armatureComponent.isUGUI = _isUGUI;
            }

            armatureComponent._armature = armature;

            armature._init(
                dataPackage.armature, dataPackage.skin,
                armatureDisplay, armatureComponent, _eventManager
                );

            _armatureGameObject = null;

            return(armature);
        }
        void IPlayerDeckTrackerInterface.TrackDeck(
            Models.Client.Decklist decklist)
        {
            Reset();

            IEventDispatcher eventDispatcher = _eventDispatcherFactory.Create();

            _viewModel =
                new PlayerDeckTrackerViewModel(
                    _cardInfoProvider,
                    _configurationSource,
                    eventDispatcher,
                    _viewEventDispatcher,
                    decklist);

            _cancellation = new CancellationTokenSource();

            Task.Run(
                async() =>
            {
                using (IEventStream eventStream = _eventStreamFactory.Create())
                {
                    while (true)
                    {
                        object @event = await eventStream.ReadNext(_cancellation.Token);
                        if (@event == null)
                        {
                            return;
                        }

                        eventDispatcher.DispatchEvent(@event);
                    }
                }
            });

            _view = new PlayerDeckTrackerView(_viewModel);

            _view.Show();
        }
Exemplo n.º 54
0
        /// <summary>
        /// Registers the event publisher.
        /// </summary>
        /// <param name="model">The model.</param>
        private void RegisterEventPublisher(ComponentModel model)
        {
            EventInfo[] events = model.Service.GetEvents();

            foreach (EventInfo e in events)
            {
                object[] attrs = e.GetCustomAttributes(typeof(EventPublisherAttribute), true);
                if (attrs.Length > 0)
                {
                    EventPublisherAttribute publisherAttr = (EventPublisherAttribute)attrs[0];
                    IEventDispatcher        dispatcher    = Kernel[typeof(IEventDispatcher)] as IEventDispatcher;
                    if (dispatcher != null)
                    {
                        dispatcher.RegisterEventPublisher(
                            publisherAttr.Topic,
                            publisherAttr.Description,
                            publisherAttr.EventScope,
                            e);
                    }
                }
            }
        }
Exemplo n.º 55
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DownloaderFile"/> class.
        /// </summary>
        public DownloaderFile(
            IIO io,
            Config config,
            ITransport transport,
            IEventDispatcher eventDispatcher = null,
            ICache cache           = null,
            IFileSystem fileSystem = null)
        {
            this.io              = io;
            this.config          = config;
            this.transport       = transport;
            this.eventDispatcher = eventDispatcher;
            this.cache           = cache;
            this.fileSystem      = fileSystem ?? new FileSystemLocal();

            if (CacheFileSystem.GCIsNecessary(cache))
            {
                cache.GC(config.Get(Settings.CacheFilesTTL), config.Get(Settings.CacheFilesMaxSize));
            }

            lastCacheWrites = new Dictionary <string, string>();
        }
Exemplo n.º 56
0
        /// <summary>
        ///     Binds the lifetime of the instance to the <see cref="eventDispatcher" />.
        /// </summary>
        /// <param name="self"></param>
        /// <param name="eventDispatcher"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"></exception>
        public static PooledObjectOperation <GameObject> BindTo(this PooledObjectOperation <GameObject> self,
                                                                IEventDispatcher eventDispatcher)
        {
            if (eventDispatcher == null)
            {
                self.Dispose();
                throw new ArgumentNullException(nameof(eventDispatcher));
            }

            void OnDispatch()
            {
                if (!self.IsDisposed)
                {
                    self.Dispose();
                }

                eventDispatcher.OnDispatch -= OnDispatch;
            }

            eventDispatcher.OnDispatch += OnDispatch;
            return(self);
        }
Exemplo n.º 57
0
        public ApiClient(IOptions <ApiClientConfiguration> configuration, TokenContainer token, HttpClient http, CommandMapper commandMapper, QueryMapper queryMapper, IExceptionHandler exceptionHandler, IEventDispatcher eventDispatcher, Interop interop)
        {
            Ensure.NotNull(configuration, "configuration");
            Ensure.NotNull(token, "token");
            Ensure.NotNull(http, "http");
            Ensure.NotNull(commandMapper, "commandMapper");
            Ensure.NotNull(queryMapper, "queryMapper");
            Ensure.NotNull(exceptionHandler, "exceptionHandler");
            Ensure.NotNull(eventDispatcher, "eventDispatcher");
            Ensure.NotNull(interop, "interop");
            this.configuration    = configuration.Value;
            this.token            = token;
            this.http             = http;
            this.commandMapper    = commandMapper;
            this.queryMapper      = queryMapper;
            this.exceptionHandler = exceptionHandler;
            this.eventDispatcher  = eventDispatcher;
            this.interop          = interop;

            http.BaseAddress = this.configuration.ApiUrl;
            EnsureAuthorization();
        }
Exemplo n.º 58
0
        /// <summary>
        /// Set the container on the view model and resolve the basic dependencies
        /// </summary>
        public static void SetContainer(IContainer container)
        {
            _container = container;

            if (_container.IsRegistered <IGlobalVariablesService>())
            {
                _globalVariables = _container.Resolve <IGlobalVariablesService>();
            }

            if (_container.IsRegistered <ILogger>())
            {
                _logger = _container.Resolve <ILogger>();
            }

            if (_container.IsRegistered <IViewModelsManager>())
            {
                _vmManager = _container.Resolve <IViewModelsManager>();
            }

            if (_container.IsRegistered <ILocalizationManager>())
            {
                _localization = _container.Resolve <ILocalizationManager>();
            }

            if (_container.IsRegistered <IObjectMapper>())
            {
                _mapper = _container.Resolve <IObjectMapper>();
            }

            if (_container.IsRegistered <IEventDispatcher>())
            {
                _eventDispatcher = _container.Resolve <IEventDispatcher>();
            }

            if (_container.IsRegistered <IRepositoryManager>())
            {
                _repositoryManager = _container.Resolve <IRepositoryManager>();
            }
        }
Exemplo n.º 59
0
        public void Ctor()
        {
            this._dispatcher = new EventDispatcher();

            this._dispatcher.Subscribe(new ActionEventHandler <ProjectEvent, ProjectCreatedEventArgument>(
                                           e =>
            {
                Assert.IsNotNull(e.Subject.Project);
                ++this._counter;
            }));

            this._dispatcher.Subscribe(new Action <ProjectRemovedEventArgument>(
                                           e =>
            {
                Assert.IsNotNull(e.Subject.Project);

                ++this._counter;
            }));

            this._dispatcher.Subscribe(new LowPriorityEventHandler());
            this._dispatcher.Subscribe(new HightPriorityEventHandler());
        }
        public bool dispatchEvent(EventX e)
        {
            bool bubbles = e.bubbles;

            if (!bubbles && (mEventListeners == null || mEventListeners.ContainsKey(e.type) == false))
            {
                return(false);
            }

            IEventDispatcher previousTarget = e.target;

            e.setTarget(mTarget);

            bool b = invokeEvent(e);

            if (previousTarget != null)
            {
                e.setTarget(previousTarget);
            }

            return(b);
        }