Ejemplo n.º 1
0
        public static SynchronousViewManagerEventDispatcherConfiguationBuilder UseSynchronousViewManangerEventDispatcher(
            this EventDispatcherConfigurationBuilder builder, params IViewManager[] viewManagers)
        {
            var viewManagerConfigurationContainer = new ConfigurationContainer();

            builder.UseEventDispatcher(context =>
            {
                var viewManagerContext = viewManagerConfigurationContainer.CreateContext();

                context.AddChildContext(viewManagerContext);

                var eventDispatcher = new SynchronousViewManagerEventDispatcher(
                    context.Get <IEventStore>(),
                    context.Get <IAggregateRootRepository>(),
                    context.Get <IDomainEventSerializer>(),
                    context.Get <IDomainTypeNameMapper>(),
                    viewManagers);

                var contextItems = viewManagerContext.GetOrDefault <IDictionary <string, object> >();
                if (contextItems != null)
                {
                    eventDispatcher.SetContextItems(contextItems);
                }

                return(eventDispatcher);
            });

            return(new SynchronousViewManagerEventDispatcherConfiguationBuilder(viewManagerConfigurationContainer));
        }
        public static SynchronousViewManagerEventDispatcherConfiguationBuilder UseSynchronousViewManangerEventDispatcher(
            this EventDispatcherConfigurationBuilder builder, params IViewManager[] viewManagers)
        {
            var viewManagerConfigurationContainer = new ConfigurationContainer();

            builder.UseEventDispatcher(context =>
            {
                var viewManagerContext = viewManagerConfigurationContainer.CreateContext();

                context.AddChildContext(viewManagerContext);

                var eventDispatcher = new SynchronousViewManagerEventDispatcher(
                    context.Get<IAggregateRootRepository>(),
                    context.Get<IDomainEventSerializer>(),
                    context.Get<IDomainTypeNameMapper>(),
                    viewManagers);

                var contextItems = viewManagerContext.GetOrDefault<IDictionary<string, object>>();
                if (contextItems != null)
                {
                    eventDispatcher.SetContextItems(contextItems);
                }

                return eventDispatcher;
            });

            return new SynchronousViewManagerEventDispatcherConfiguationBuilder(viewManagerConfigurationContainer);
        }