Exemplo n.º 1
0
 public static void Subscriber(ICommandSubscriber commandSubscriber, params object[] commandHandlers)
 {
     foreach (var commandHandler in commandHandlers)
     {
         Subscriber(commandSubscriber, commandHandler);
     }
 }
Exemplo n.º 2
0
 protected TransientSubscriber(IGeneralBus bus) : this((IBus)bus)
 {
     if (bus == null)
     {
         throw new ArgumentNullException(nameof(bus));
     }
     _commandSubscriber = bus;
 }
Exemplo n.º 3
0
        private IEnumerable <ICommandSubscriber> CommandForwarder()
        {
            ICommandSubscriber tool = _currentTool as ICommandSubscriber;

            if (tool != null)
            {
                yield return(tool);
            }
        }
Exemplo n.º 4
0
 public ApplicationSvc(
     IConfiguredConnection conn,
     ICommandSubscriber subscriber)
     : base(subscriber)
 {
     _conn = conn;
     _repo = conn.GetCorrelatedRepository();
     _rm   = new FilteredPoliciesRM(conn);
     Subscribe <ApplicationMsgs.CreateApplication>(this);
 }
Exemplo n.º 5
0
        public void RemoveCommandSubscriber(ICommandSubscriber manager)
        {
            if (_forwardManagers.Remove(manager))
            {
                manager.CommandManager.CommandInvalidated -= HandleCommandInvalidated;
                manager.CommandManager.ManagerInvalidated -= HandleManagerInvalidated;

                InvalidateManager();
            }
        }
Exemplo n.º 6
0
        public static void Subscriber(ICommandSubscriber commandSubscriber, IEventSubscriber eventSubscriber, params object[] handlers)
        {
            foreach (var eventHanlder in handlers)
            {
                Subscriber(eventSubscriber, eventHanlder);
            }

            foreach (var commandHandler in handlers)
            {
                Subscriber(commandSubscriber, commandHandler);
            }
        }
Exemplo n.º 7
0
        public AccountCommandHandler(IRepository repo, ICommandSubscriber bus, IClock clock = null)
        {
            _repo = repo;

            _disposer = new CompositeDisposable(
                bus.Subscribe <CreateAccount>(this),
                bus.Subscribe <SetOverdraftLimit>(this),
                bus.Subscribe <SetDailyWireTransferLimit>(this),
                bus.Subscribe <DepositCheque>(this),
                bus.Subscribe <DepositCash>(this),
                bus.Subscribe <WithdrawCash>(this),
                bus.Subscribe <TryWireTransfer>(this),
                bus.Subscribe <StartNewBusinessDay>(this));
        }
Exemplo n.º 8
0
        public PolicySvc(
            IConfiguredConnection conn,
            ICommandSubscriber cmdSource)
            : base(cmdSource)
        {
            _repo = conn.GetCorrelatedRepository(caching: true);

            Subscribe <ApplicationMsgs.CreateRole>(this);
            Subscribe <PolicyUserMsgs.AddPolicyUser>(this);
            Subscribe <PolicyUserMsgs.AddRole>(this);
            Subscribe <PolicyUserMsgs.RemoveRole>(this);
            Subscribe <PolicyUserMsgs.DeactivateUser>(this);
            Subscribe <PolicyUserMsgs.ReactivateUser>(this);
        }
Exemplo n.º 9
0
        public AccountCommandHandler(IRepository repository, ICommandSubscriber dispatcher)
        {
            _repository = repository;

            _disposable = new CompositeDisposable
            {
                dispatcher.Subscribe <CreateAccount>(this),
                dispatcher.Subscribe <SetODLimit>(this),
                dispatcher.Subscribe <SetDailyWireTransferLimit>(this),
                dispatcher.Subscribe <DepositCheque>(this),
                dispatcher.Subscribe <DepositCash>(this),
                dispatcher.Subscribe <WithdrawCash>(this),
            };
        }
Exemplo n.º 10
0
        public AccountCommandHandler(IRepository repository, ICommandSubscriber dispatcher)
        {
            _repository = repository;

            _disposable = new CompositeDisposable
            {
                dispatcher.Subscribe <CreateAccount>(this),
                dispatcher.Subscribe <ConfigureOverdraftLimit>(this),
                dispatcher.Subscribe <ConfigureDailyWireTransferLimit>(this),
                dispatcher.Subscribe <DepositCheque>(this),
                dispatcher.Subscribe <DepositCash>(this),
                dispatcher.Subscribe <WithdrawCash>(this),
                dispatcher.Subscribe <TransferWireFund>(this)
            };
        }
Exemplo n.º 11
0
        static void Subscriber(ICommandSubscriber commandSubscriber, object commandHandler)
        {
            var handlerTypes = commandHandler.GetType().GetInterfaces()
                               .Where(m => m.IsGenericType && m.GetGenericTypeDefinition() == typeof(ICommandHandler <,>));

            if (handlerTypes != null && handlerTypes.Count() > 0)
            {
                var subscribeMethod = typeof(ICommandSubscriber).GetMethod(nameof(ICommandSubscriber.SubscribeAsync));
                foreach (var handlerType in handlerTypes)
                {
                    var commandTypes = handlerType.GetGenericArguments();
                    subscribeMethod.MakeGenericMethod(commandTypes).Invoke(commandSubscriber, new object[] { commandHandler });
                }
            }
        }
Exemplo n.º 12
0
        public void AddCommandSubscriber(ICommandSubscriber manager)
        {
            if (manager == null)
            {
                return;
            }

            if (!_forwardManagers.Contains(manager))
            {
                manager.CommandManager.CommandInvalidated += HandleCommandInvalidated;
                manager.CommandManager.ManagerInvalidated += HandleManagerInvalidated;

                _forwardManagers.Add(manager);
                InvalidateManager();
            }
        }
 /// <summary>
 /// Creates a <see cref="ReactiveTransientSubscriber"/> with the injected dispatcher.
 /// </summary>
 /// <param name="bus">The dispatcher on which to subscribe to commands.</param>
 /// <exception cref="ArgumentNullException"><c>bus</c> is <c>null</c></exception>
 protected ReactiveTransientSubscriber(IDispatcher bus) : this((IBus)bus)
 {
     _commandSubscriber = bus ?? throw new ArgumentNullException(nameof(bus));
 }
 protected TransientSubscriber(ICommandSubscriber subscriber)
 {
     _commandSubscriber = subscriber ?? throw new ArgumentNullException(nameof(subscriber));
 }
Exemplo n.º 15
0
 internal void InstantiateCommandSubscriber()
 {
     CommandSubscriber = Container.GetInstance <ICommandSubscriber>();
 }
Exemplo n.º 16
0
        private void SelectLayer(Guid layerUid)
        {
            if (_selectedLayer == layerUid)
            {
                return;
            }

            if (_selectedLayerRef != null)
            {
                UnbindSelectedLayerEvents(_selectedLayerRef);

                ICommandSubscriber comLayer = _selectedLayerRef as ICommandSubscriber;
                if (comLayer != null)
                {
                    _commandManager.RemoveCommandSubscriber(comLayer);
                }

                _selectedLayerRef.Deactivate();
            }

            if (layerUid == null || !_layerPresenters.ContainsKey(layerUid))
            {
                _selectedLayer    = Guid.Empty;
                _selectedLayerRef = null;

                InvalidateLayerCommands();
                RefreshGridVisibility();
                OnPointerEventResponderChanged(EventArgs.Empty);
                return;
            }

            _selectedLayer    = layerUid;
            _selectedLayerRef = _layerPresenters[_selectedLayer];

            _info.ActionUpdateCoordinates("");
            _gridLayer.IsVisible = true;

            if (_selectedLayerRef != null)
            {
                BindSelectedLayerEvents(_selectedLayerRef);

                ICommandSubscriber comLayer = _selectedLayerRef as ICommandSubscriber;
                if (comLayer != null)
                {
                    _commandManager.AddCommandSubscriber(comLayer);
                }

                if (_selectedLayerRef is LevelLayerPresenter)
                {
                    //_gridLayer.IsVisible = CommandManager.IsSelected(CommandKey.ViewGrid);
                    _gridLayer.GridColor    = (_selectedLayerRef as LevelLayerPresenter).Layer.GridColor;
                    _gridLayer.GridSpacingX = (_selectedLayerRef as LevelLayerPresenter).Layer.GridWidth;
                    _gridLayer.GridSpacingY = (_selectedLayerRef as LevelLayerPresenter).Layer.GridHeight;
                }

                _selectedLayerRef.Activate();
            }

            InvalidateLayerCommands();
            OnPointerEventResponderChanged(EventArgs.Empty);

            _info.RefreshContentInfo();
        }