/// <summary> /// Registers a <see cref="Views.ViewManagerEventDispatcher"/> to manage the given views. Can be called multiple times in order to register /// multiple "pools" of views (each will be managed by a dedicated worker thread). /// </summary> public ViewManagerEventDispatcherConfiguationBuilder UseViewManagerEventDispatcher(params IViewManager[] viewManagers) { var viewManagerConfigurationContainer = new ConfigurationContainer(); UseEventDispatcher(context => { var viewManagerContext = viewManagerConfigurationContainer.CreateContext(); context.AddChildContext(viewManagerContext); var eventDispatcher = new ViewManagerEventDispatcher( context.Get <IAggregateRootRepository>(), context.Get <IEventStore>(), context.Get <IDomainEventSerializer>(), context.Get <IDomainTypeNameMapper>(), viewManagers); var waitHandle = viewManagerContext.GetOrDefault <ViewManagerWaitHandle>(); if (waitHandle != null) { waitHandle.Register(eventDispatcher); } var maxDomainEventsPerBatch = viewManagerContext.GetOrDefault <int>(); if (maxDomainEventsPerBatch > 0) { eventDispatcher.MaxDomainEventsPerBatch = maxDomainEventsPerBatch; } var viewManagerProfiler = viewManagerContext.GetOrDefault <IViewManagerProfiler>(); if (viewManagerProfiler != null) { eventDispatcher.SetProfiler(viewManagerProfiler); } var contextItems = viewManagerContext.GetOrDefault <IDictionary <string, object> >(); if (contextItems != null) { eventDispatcher.SetContextItems(contextItems); } var autoDistributionViewManagerEventDispatcher = viewManagerContext.GetOrDefault <AutoDistributionViewManagerEventDispatcher>(); if (autoDistributionViewManagerEventDispatcher != null) { autoDistributionViewManagerEventDispatcher.Register(eventDispatcher); return(autoDistributionViewManagerEventDispatcher); } return(eventDispatcher); }); return(new ViewManagerEventDispatcherConfiguationBuilder(viewManagerConfigurationContainer)); }
/// <summary> /// Registers a <see cref="Views.ViewManagerEventDispatcher"/> to manage the given views. Can be called multiple times in order to register /// multiple "pools" of views (each will be managed by a dedicated worker thread). /// </summary> public ViewManagerEventDispatcherConfigurationBuilder UseViewManagerEventDispatcher(params IViewManager[] viewManagers) { var viewManagerConfigurationContainer = new NewConfigurationContainer(_services); UseEventDispatcher(context => { var scope = context.CreateScope(); var eventDispatcher = new ViewManagerEventDispatcher( scope.ServiceProvider.GetService <IAggregateRootRepository>(), scope.ServiceProvider.GetService <IEventStore>(), scope.ServiceProvider.GetService <IDomainEventSerializer>(), scope.ServiceProvider.GetService <IDomainTypeNameMapper>(), viewManagers); var waitHandle = scope.ServiceProvider.GetService <ViewManagerWaitHandle>(); if (waitHandle != null) { waitHandle.Register(eventDispatcher); } var configuration = scope.ServiceProvider.GetService <ViewManagerEventDispatcherConfiguration>(); if (configuration?.MaxDomainEventsPerBatch > 0) { eventDispatcher.MaxDomainEventsPerBatch = configuration.MaxDomainEventsPerBatch; } var viewManagerProfiler = scope.ServiceProvider.GetService <IViewManagerProfiler>(); if (viewManagerProfiler != null) { eventDispatcher.SetProfiler(viewManagerProfiler); } var contextItems = scope.ServiceProvider.GetService <IDictionary <string, object> >(); if (contextItems != null) { eventDispatcher.SetContextItems(contextItems); } var autoDistributionViewManagerEventDispatcher = scope.ServiceProvider.GetService <AutoDistributionViewManagerEventDispatcher>(); if (autoDistributionViewManagerEventDispatcher != null) { autoDistributionViewManagerEventDispatcher.Register(eventDispatcher); return(autoDistributionViewManagerEventDispatcher); } return(eventDispatcher); }); return(new ViewManagerEventDispatcherConfigurationBuilder(viewManagerConfigurationContainer)); }