Example #1
0
        private Automaton(IEventSink context, IEventSink state)

        {
            this.State = state;

            this.Context = context;
        }
Example #2
0
 public void RemoveListener(IEventSink eventSink)
 {
     if (!(eventSink is null))
     {
         Log.Unregister(eventSink);
     }
 }
Example #3
0
        public MainPresenter(IApplicationManager applicationManager, IMainView view, IStorage storage, IUndoStack undoStack, IEventSink eventSink)
        {
            this.applicationManager = applicationManager;
            this.view      = view;
            this.storage   = storage;
            this.undoStack = undoStack;
            this.eventSink = eventSink;

            view.CreateFileRequest    += View_CreateFile;
            view.OpenFileRequest      += View_OpenFile;
            view.CreateTaskRequest    += View_CreateTask;
            view.ModifyTaskRequest    += View_ModifyTask;
            view.DeleteTaskRequest    += View_DeleteTask;
            view.SetTaskDoneRequest   += View_SetTaskDone;
            view.SetTaskUndoneRequest += View_SetTaskUndone;
            view.UndoRequest          += View_Undo;
            view.RedoRequest          += View_Redo;
            view.ExitRequest          += View_Exit;

            //storage.TaskCreated += UpdateView;
            //storage.TaskDeleted += UpdateView;
            //storage.TaskUpdated += UpdateView;
            //storage.FileOpened += Storage_FileOpened;
            eventSink.FileOpened  += Storage_FileOpened;
            eventSink.TaskChanged += Storage_TaskChanged;

            undoStack.CommandPerformed += UndoStack_OperationPerformed;

            eventSink.ErrorOccurred += ErrorSink_ErrorOccurred;
        }
        public ConfirmationService(
            IUserRepository userRepository,
            IMailer mailer,
            IValidationRequestsRepository validationRequestsRepository, 
            IEventSink userManagementEventSink, 
            ConfirmationSettings confirmationSettings, 
            IGitlabUserRegistrar gitlabUserRegistrar, 
            IRedmineUserRegistrar redmineUserRegistrar)
        {
            Require.NotNull(userRepository, nameof(userRepository));
            Require.NotNull(mailer, nameof(mailer));
            Require.NotNull(validationRequestsRepository, nameof(validationRequestsRepository));
            Require.NotNull(userManagementEventSink, nameof(userManagementEventSink));
            Require.NotNull(confirmationSettings, nameof(confirmationSettings));
            Require.NotNull(gitlabUserRegistrar, nameof(gitlabUserRegistrar));
            Require.NotNull(redmineUserRegistrar, nameof(redmineUserRegistrar));

            _userRepository = userRepository;
            _mailer = mailer;
            _validationRequestsRepository = validationRequestsRepository;
            _userManagementEventSink = userManagementEventSink;
            _confirmationSettings = confirmationSettings;
            _gitlabUserRegistrar = gitlabUserRegistrar;
            _redmineUserRegistrar = redmineUserRegistrar;
        }
Example #5
0
        public IDisposable Subscribe(IEventSink eventSink, object filterInstance, EndpointReference subscriptionManagerReference, IIncomingHeaders headers)
        {
            var selectorSetHeader = headers.GetHeader <SelectorSetHeader>();
            var target            = selectorSetHeader.Selectors.ExtractObjectName();
            var listenerId        = GenerateNextListenerId();

            subscriptionManagerReference.AddProperty(new NotificationListenerListHeader(listenerId.ToString()), false);
            var subscriptionInfo = new SubscriptionInfo(eventSink, listenerId);

            lock (_subscriptions)
            {
                _subscriptions.Add(subscriptionInfo);
            }
            _server.AddNotificationListener(target, subscriptionInfo.OnNotification, subscriptionInfo.FilterNotification, listenerId);

            return(new SubscriptionRemover(
                       () =>
            {
                lock (_subscriptions)
                {
                    var toRemove = _subscriptions.Single(x => x.EventSink == eventSink);
                    _server.RemoveNotificationListener(target, toRemove.OnNotification, toRemove.FilterNotification, toRemove.ListenerId);
                    _subscriptions.Remove(toRemove);
                }
            }));
        }
 private Task <byte[]> OnListen(MethodCall call)
 {
     if (_activeSink != null)
     {
         try
         {
             _handler.OnCancel(null);
         }
         catch (Exception e)
         {
             TizenLog.Error($"{_channel.Name}: Failed to close existing event stream. {e.Message}");
         }
     }
     try
     {
         _activeSink = new EventSinkImpl(this);
         _handler.OnListen(call.Arguments, _activeSink);
         return(Task.FromResult(_channel.Codec.EncodeSuccessEnvelope(null)));
     }
     catch (Exception e)
     {
         _activeSink = null;
         TizenLog.Error($"{_channel.Name}: Failed to open event stream. {e.Message}");
         return(Task.FromResult(_channel.Codec.EncodeErrorEnvelope("error", e.Message, null)));
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultEventService"/> class.
 /// </summary>
 /// <param name="options">The options.</param>
 /// <param name="context">The context.</param>
 /// <param name="sink">The sink.</param>
 /// <param name="clock">The clock.</param>
 public DefaultEventService(IdentityServerOptions options, IHttpContextAccessor context, IEventSink sink, ISystemClock clock)
 {
     Options = options;
     Context = context;
     Sink    = sink;
     Clock   = clock;
 }
Example #8
0
 public EventSinkTest()
 {
     _accountGetterServiceMock = new Mock <IAccountGetterService>();
     _accountRepositoryMock    = new Mock <IAccountRepository>();
     _communicationBusMock     = new Mock <ICommunicationBus>();
     _service = new IdentityServerEventSink(_accountGetterServiceMock.Object, _accountRepositoryMock.Object,
                                            _communicationBusMock.Object);
 }
Example #9
0
 public void AddListener(IEventSink eventSink)
 {
     if (eventSink is XmppEventSink xmppEventSink)
     {
         this.bareJid = xmppEventSink.Client?.BareJID;
     }
     Log.Register(eventSink);
 }
Example #10
0
 public override void Start(IEventSink sink)
 {
     Validate.ArgumentNotNull(parameter: sink, parameterName: nameof(sink));
     Stop();
     this._sinkReference    = new WeakReference(target: sink);
     this._handlingDelegate = Handler;
     Automation.AddStructureChangedEventHandler(element: this._root.AutomationElement, scope: (TreeScope)this._scope, eventHandler: this._handlingDelegate);
 }
Example #11
0
        public OrderManagment(IOrderRepository orderRepository, IEventSink orderManagmentEventSink)
        {
            Require.NotNull(orderRepository, nameof(orderRepository));
            Require.NotNull(orderManagmentEventSink, nameof(orderManagmentEventSink));

            _orderRepository         = orderRepository;
            _orderManagmentEventSink = orderManagmentEventSink;
        }
Example #12
0
 public EventMonitor(string user, string operation, string details, int acceptableDurationMilliseconds, IEventSink sink)
 {
     this.user      = user;
     this.operation = operation;
     this.details   = details;
     this.acceptableDurationMilliseconds = acceptableDurationMilliseconds;
     this.sink = sink;
 }
        public OrderManagment(IOrderRepository orderRepository, IEventSink orderManagmentEventSink)
        {
            Require.NotNull(orderRepository, nameof(orderRepository));
            Require.NotNull(orderManagmentEventSink, nameof(orderManagmentEventSink));

            _orderRepository = orderRepository;
            _orderManagmentEventSink = orderManagmentEventSink;
        }
Example #14
0
 public DependableConfiguration UseEventSink(IEventSink eventSink)
 {
     if (eventSink == null)
     {
         throw new ArgumentNullException("eventSink");
     }
     _eventSinks.Add(eventSink);
     return(this);
 }
Example #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StateBase&lt;AI&gt;"/> class.
 /// </summary>
 /// <param name="automaton">The automaton.</param>
 /// <param name="eventSink">The event sink.</param>
 protected StateBase(AI automaton, IEventSink eventSink)
 {
     if (automaton == null || eventSink == null)
     {
         throw new NullReferenceException();
     }
     this.automaton = automaton;
     this.eventSink = eventSink;
 }
        public TaskPropertiesPresenter(ITaskPropertiesView view, IStorage storage, IEventSink eventSink)
        {
            this.view      = view;
            this.storage   = storage;
            this.eventSink = eventSink;

            view.OK     += View_OK;
            view.Cancel += View_Cancel;
        }
Example #17
0
 public override void Start(IEventSink sink)
 {
     Validate.ArgumentNotNull(parameter: sink, parameterName: nameof(sink));
     Stop();
     this._sinkReference        = new WeakReference(target: sink);
     this._sinkReference.Target = sink;
     this._handlingDelegate     = Handler;
     Automation.AddAutomationFocusChangedEventHandler(eventHandler: this._handlingDelegate);
 }
 public override void Start(IEventSink sink)
 {
     Validate.ArgumentNotNull(parameter: sink, parameterName: nameof(sink));
     Stop();
     Log.Out(msg: "{0} Start", (object)ToString());
     this._sinkReference    = new WeakReference(target: sink);
     this._handlingDelegate = Handler;
     Automation.AddAutomationEventHandler(eventId: this._eventId, element: this._root.AutomationElement, scope: (TreeScope)this._scope, eventHandler: this._handlingDelegate);
 }
Example #19
0
        public void Send(IEventSink source, ICommand command)

        {
            var target = source == this.State ? this.Context : this.State;



            target.Receive(command);
        }
Example #20
0
            public void InitializeContext()
            {
                appHost = new AppHostForAzureTesting();
                appHost.Init();
                appHost.Start(BaseUrl);

                client             = new JsonServiceClient(BaseUrl);
                subscriptionsStore = appHost.Resolve <ISubscriptionStore>();
                eventSink          = appHost.Resolve <IEventSink>();
            }
 public AnimalRegistration(
     AppDbContext ctx,
     IEventSink eventSink,
     ISystemClock clock
     )
 {
     _ctx       = ctx;
     _eventSink = eventSink;
     _clock     = clock;
 }
Example #22
0
 public HandlerService(
     IPushTokenService pushTokenService,
     IdentityServerOptions options,
     IHttpContextAccessor context,
     IEventSink sink,
     ISystemClock clock)
     : base(options, context, sink, clock)
 {
     PushTokenService = pushTokenService;
 }
Example #23
0
        public StateBase(T automation, IEventSink eventSink)
        {
            if (automation == null || eventSink == null)
            {
                throw new ArgumentNullException();
            }

            this.automation = automation;
            this.eventSink  = eventSink;
        }
        public GamePadComponent(IEventSink <GamePadEventData> eventSink)
        {
            this.eventSink          = eventSink;
            TriggerDownTreshold     = 0.15f;
            ThumbstickDownTreshold  = 0.5f;
            TriggerDeltaTreshold    = 0.1f;
            ThumbStickDeltaTreshold = 0.1f;

            currentStates  = new GamePadState[GamePad.MaximumGamePadCount];
            previousStates = new GamePadState[GamePad.MaximumGamePadCount];
        }
Example #25
0
        public bool HandleCommand(ICommand message, IEventSink eventPublisher)
        {
            var method = GetType().GetMethod("Handle", new[] { message.GetType(), typeof(IEventSink) });

            if (method == null)
            {
                return(false);
            }
            method.Invoke(this, new object[] { message, eventPublisher });
            return(true);
        }
Example #26
0
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="DefaultEventService"/> class.
 /// </summary>
 /// <param name="options">The options.</param>
 /// <param name="context">The context.</param>
 /// <param name="sink">The sink.</param>
 public DefaultEventService(
     EventOptions eventOptions,
     IHttpContextAccessor httpContextAccessor,
     IDateTimeAccessor dateTimeAccessor,
     IEventSink eventSink)
 {
     this.eventOptions        = eventOptions;
     this.httpContextAccessor = httpContextAccessor;
     this.dateTimeAccessor    = dateTimeAccessor;
     this.eventSink           = eventSink;
 }
Example #27
0
 public void Handle(NewCommand command, IEventSink eventPublisher)
 {
     if (HasBeenCreated)
     {
         eventPublisher.Publish(new CouldNotProcessNewAsTradeAlreadyExists(Id));
     }
     else
     {
         eventPublisher.Publish(new NewTradeCreated(Id, command.SomeData));
     }
 }
Example #28
0
        /// <summary>
        /// If the event sink <paramref name="EventSink"/> should be avoided when logging the event.
        /// </summary>
        /// <param name="EventSink">Event sink</param>
        /// <returns>If the event sink should be avoided.</returns>
        public void Avoid(IEventSink EventSink)
        {
            if (this.toAvoid is null)
            {
                this.toAvoid = new LinkedList <IEventSink>();
            }

            if (!this.toAvoid.Contains(EventSink))
            {
                this.toAvoid.AddLast(EventSink);
            }
        }
 public PacManGame(
     IEventSink eventSink,
     IMapLoader <ITilemap> mapLoader,
     ICollisionDetection collisionDetection,
     ISpriteRenderer renderer)
 {
     _eventSink          = eventSink;
     _mapLoader          = mapLoader;
     _gameState          = new GameState(3);
     _collisionDetection = collisionDetection;
     _renderer           = renderer;
 }
Example #30
0
        private void LoadEventSinks()
        {
            var sinksSection = _config.GetSection("Sinks");
            var sinkSections = sinksSection.GetChildren();
            int sinksStarted = 0;
            int sinksFailed  = 0;

            foreach (var sinkSection in sinkSections)
            {
                string id       = _config.GetChildConfig(sinkSection.Path, ConfigConstants.ID);
                string sinkType = _config.GetChildConfig(sinkSection.Path, ConfigConstants.SINK_TYPE);
                var    factory  = _sinkFactoryCatalog.GetFactory(sinkType);
                if (factory != null)
                {
                    IEventSink sink = null;
                    try
                    {
                        if (string.IsNullOrWhiteSpace(id))
                        {
                            throw new Exception("Sink id is required.");
                        }

                        sink = factory.CreateInstance(sinkType, CreatePlugInContext(sinkSection));
                        sink.Start();
                        _sinks[sink.Id] = sink;
                        sinksStarted++;
                    }
                    catch (Exception ex)
                    {
                        sinksFailed++;
                        _logger.LogError(0, ex, $"Unable to load event sink {id} exception");

                        // If the sink fails to start due to "Rate limit exceeded" error,
                        // add it to the sinks that need to be retarted
                        if (ex is RateExceededException)
                        {
                            _sinksToRestart[sink.Id] = sink;
                        }
                    }
                }
                else
                {
                    sinksFailed++;
                    _logger.LogError("Sink Type {0} is not recognized.", sinkType);
                }
            }
            _metrics.PublishCounters(string.Empty, MetricsConstants.CATEGORY_PROGRAM, CounterTypeEnum.CurrentValue, new Dictionary <string, MetricValue>()
            {
                { MetricsConstants.SINKS_STARTED, new MetricValue(sinksStarted) },
                { MetricsConstants.SINKS_FAILED_TO_START, new MetricValue(sinksFailed) }
            });
        }
Example #31
0
        void DispatchAndHandleException(IEventSink sink, EventType type, Dictionary <string, object> data)
        {
            try
            {
                sink.Dispatch(type, data);
            }
            catch (Exception e)
            {
                if (e.IsFatal())
                {
                    throw;
                }

                _exceptionLogger.Log(e);
            }
        }
Example #32
0
        private async Task LoadEventSinks(CancellationToken stopToken)
        {
            var sinksSection = _config.GetSection("Sinks");
            var sinkSections = sinksSection.GetChildren();
            var sinksStarted = 0;
            var sinksFailed  = 0;

            foreach (var sinkSection in sinkSections)
            {
                var id       = _config.GetChildConfig(sinkSection.Path, ConfigConstants.ID);
                var sinkType = _config.GetChildConfig(sinkSection.Path, ConfigConstants.SINK_TYPE);
                var factory  = _sinkFactoryCatalog.GetFactory(sinkType);
                if (factory != null)
                {
                    IEventSink sink = null;
                    try
                    {
                        if (string.IsNullOrWhiteSpace(id))
                        {
                            throw new Exception("Sink id is required.");
                        }

                        sink = factory.CreateInstance(sinkType, CreatePlugInContext(sinkSection));
                        await sink.StartAsync(stopToken);

                        _sinks[sink.Id] = sink;
                        sinksStarted++;
                    }
                    catch (Exception ex)
                    {
                        sinksFailed++;
                        _logger.LogError(ex, $"Unable to load event sink {id}");
                    }
                }
                else
                {
                    sinksFailed++;
                    _logger.LogError("Sink Type {0} is not recognized.", sinkType);
                }
            }
            _metrics.PublishCounters(string.Empty, MetricsConstants.CATEGORY_PROGRAM, CounterTypeEnum.CurrentValue, new Dictionary <string, MetricValue>()
            {
                { MetricsConstants.SINKS_STARTED, new MetricValue(sinksStarted) },
                { MetricsConstants.SINKS_FAILED_TO_START, new MetricValue(sinksFailed) }
            });
        }
        public ProjectProvider(
            IProjectManagerGateway projectManagerGateway,
            IVersionControlSystemGateway versionControlSystemGateway,
            IProjectRepository projectRepository,
            IEventSink eventSink,
            IUserRepository userRepository,
            PaginationSettings paginationSettings, IssuePaginationSettings issuePaginationSettings)
        {
            Require.NotNull(projectManagerGateway, nameof(projectManagerGateway));
            Require.NotNull(versionControlSystemGateway, nameof(versionControlSystemGateway));
            Require.NotNull(projectRepository, nameof(projectRepository));
            Require.NotNull(eventSink, nameof(eventSink));
            Require.NotNull(userRepository, nameof(userRepository));
            Require.NotNull(paginationSettings, nameof(paginationSettings));

            _projectManagerGateway = projectManagerGateway;
            _versionControlSystemGateway = versionControlSystemGateway;
            _projectRepository = projectRepository;
            _eventSink = eventSink;
            _userRepository = userRepository;
            _paginationSettings = paginationSettings;
            _issuePaginationSettings = issuePaginationSettings;
        }
 public ContactsService(IEventSink contactsEventSink)
 {
     Require.NotNull(contactsEventSink, nameof(contactsEventSink));
     _contactsEventSink = contactsEventSink;
 }
Example #35
0
 /// <summary>
 /// Registers an event sink with the listener without activating the
 /// event sink.
 /// </summary>
 /// <param name="sink">the event sink to register</param>
 /// <returns>A registration key for the event sink</returns>		
 public ISinkRegistrationKey RegisterEventSink(IEventSink sink)
 {
     if (sink == null) throw new ArgumentNullException("sink");
     EventRegistrationKey key = new EventRegistrationKey(this, sink);
     Util.LazyInitializeWithLock(ref _eventNotifier, _notifierLock)
         .AddRegistration(key);
     return key;
 }
Example #36
0
 public EventRegistrationKey(EventListenerBase listener, IEventSink sink)
 {
     Listener = listener;
     Sink = sink;
 }
Example #37
0
 public AccountState(Guid id,IEventSink events)
 {
     _account = new Account();
     _account.AccountId = id;
     Events = events;
 }
Example #38
0
 public SubscriptionInfo(IEventSink eventSink, int listenerId)
 {
     _eventSink = eventSink;
      _listenerId = listenerId;
 }