Ejemplo n.º 1
0
        public void RegisterCreatedEvent()
        {
            registry.Register(new Event(EventSource.Environment));

            Assert.NotEmpty(events);
            Assert.Single(events);
        }
Ejemplo n.º 2
0
        public void RegisterCreatedEvent()
        {
            registry.Register(new Event(new EnvironmentEventSource(), -1));

            Assert.NotEmpty(events);
            Assert.Equal(1, events.Count);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Subscribe to diagnostics info. Accesses repository to update metadata (status, errors etc.) of operations.
 /// </summary>
 public static void Listen()
 {
     _eventRegistry.Register <DiagnosticsResponseEvent>(Exchanges.Diagnostics);
     _eventBus.Subscribe((DiagnosticsResponseEvent @event) =>
     {
         using (IServiceScope scope = Services.CreateScope())
         {
             _OperationRequestRepository = scope.ServiceProvider.GetRequiredService <AnalyticsOperationRequestRepository>();
             _OperationRequestRepository.Update(@event.Operation);
             _OperationRequestRepository.SaveChanges();
         }
     });
 }
 public void Initialize(IBF2Engine engine, IEventRegistry registry)
 {
     BF2Engine = engine;
     if (BF2Engine == null)
     {
         throw new Exception();
     }
     registry.Register(1, typeof(ChallengeEvent));
     registry.Register(2, typeof(ChallengeResponseEvent));
     registry.Register(3, typeof(ConnectionTypeEvent));
     registry.Register(4, typeof(DataBlockEvent));
     registry.Register(5, typeof(CreatePlayerEvent));
     ConMethods.Initialize();
 }
        /// <summary>
        /// Sample event subsribe: Register + Subscribe
        /// </summary>
        /// <param name="app"></param>
        public static void SubscribeEvents(this IApplicationBuilder app)
        {
            IEventRegistry registry = app.ApplicationServices.GetRequiredService <IEventRegistry>();

            registry.Register <TimeSeriesAnalysisRequestEvent>(Exchanges.TimeSeries);
            registry.Register <DiagnosticsResponseEvent>(Exchanges.Diagnostics);
            registry.Register <AnalyticModuleRegistrationRequestEvent>(Exchanges.ModuleRegistration);

            DiagnosticsListener.Services = app.ApplicationServices.GetRequiredService <IServiceProvider>();

            using (IServiceScope scope = app.ApplicationServices.GetRequiredService <IServiceProvider>().CreateScope())
            {
                IEventBus         eventBus          = scope.ServiceProvider.GetRequiredService <IEventBus>();
                AnalyticsRegistry analyticsRegistry = scope.ServiceProvider.GetRequiredService <AnalyticsRegistry>();
                AnalyticsOperationRequestRepository operationRequestRepository = scope.ServiceProvider.GetRequiredService <AnalyticsOperationRequestRepository>();

                DiagnosticsListener.Initialize(registry, eventBus, operationRequestRepository, analyticsRegistry);
                DiagnosticsListener.Listen();
                DiagnosticsListener.ListenNewModules();
            }
        }
        public static void Register <TEvent>(this IEventRegistry <TEvent> registry, IEventSource source, params object[] args)
            where TEvent : class, IEvent
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            var @event = (TEvent)CreateEvent(typeof(TEvent), source, args);

            registry.Register(@event);
        }
Ejemplo n.º 7
0
        protected virtual void ConfigureEventBus(IApplicationBuilder app)
        {
            IEventRegistry registry = app.ApplicationServices.GetRequiredService <IEventRegistry>();

            registry.Register <TimeSeriesAnalysisRequestEvent>(Exchanges.TimeSeries);
            registry.Register <DiagnosticsResponseEvent>(Exchanges.Diagnostics);
            registry.Register <AnalyticModuleRegistrationRequestEvent>(Exchanges.ModuleRegistration);

            using (IServiceScope scope = app.ApplicationServices.GetRequiredService <IServiceProvider>().CreateScope())
            {
                IEventBus eventBus = scope.ServiceProvider.GetService <IEventBus>();

                eventBus.SubscribeToTopic <TimeSeriesAnalysisRequestEvent>(async(@event) =>
                {
                    using (IServiceScope scope = app.ApplicationServices.GetRequiredService <IServiceProvider>().CreateScope())
                    {
                        AnalyticsIntegrationEventHandler handler = scope.ServiceProvider.GetRequiredService <AnalyticsIntegrationEventHandler>();
                        await handler.Handle(@event, "Min");
                    }
                }, "*.min");

                eventBus.SubscribeToTopic <TimeSeriesAnalysisRequestEvent>(async(@event) =>
                {
                    using (IServiceScope scope = app.ApplicationServices.GetRequiredService <IServiceProvider>().CreateScope())
                    {
                        AnalyticsIntegrationEventHandler handler = scope.ServiceProvider.GetRequiredService <AnalyticsIntegrationEventHandler>();
                        await handler.Handle(@event, "Mean");
                    }
                }, "*.mean");

                eventBus.SubscribeToTopic <TimeSeriesAnalysisRequestEvent>(async(@event) =>
                {
                    using (IServiceScope scope = app.ApplicationServices.GetRequiredService <IServiceProvider>().CreateScope())
                    {
                        AnalyticsIntegrationEventHandler handler = scope.ServiceProvider.GetRequiredService <AnalyticsIntegrationEventHandler>();
                        await handler.Handle(@event, "Max");
                    }
                }, "*.max");
            }
        }
Ejemplo n.º 8
0
        public static void Register(this IEventRegistry registry, Type type, IEventSource source, params object[] args)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            if (!typeof(IEvent).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo()))
            {
                throw new ArgumentException($"The type '{type}' is not assignable from '{typeof(IEvent)}'.");
            }

            var @event = CreateEvent(type, source, args);

            if (registry != null)
            {
                registry.Register(@event);
            }
        }
Ejemplo n.º 9
0
 public static void Register <TEvent>(this IEventRegistry registry, IEventSource source, params object[] args)
     where TEvent : class, IEvent
 {
     registry.Register(typeof(TEvent), source, args);
 }