示例#1
0
        public static IServiceProvider CreateServiceProvider(this IEventFlowOptions eventFlowOptions,
                                                             bool validateRegistrations = true)
        {
            var rootResolver = eventFlowOptions.CreateResolver(validateRegistrations);

            if (!(rootResolver is ServiceProviderRootResolver serviceProviderRootResolver))
            {
                throw new InvalidOperationException(
                          "Make sure to configure the EventFlowOptions for IServiceProvider " +
                          "using the .UseServiceCollection(...) extension method.");
            }

            return(serviceProviderRootResolver.ServiceProvider);
        }
        public static IContainer CreateContainer(
            this IEventFlowOptions eventFlowOptions,
            bool validateRegistrations = true)
        {
            var rootResolver        = eventFlowOptions.CreateResolver(validateRegistrations);
            var autofacRootResolver = rootResolver as AutofacRootResolver;

            if (autofacRootResolver == null)
            {
                throw new InvalidOperationException(
                          "Make sure to configure the EventFlowOptions for Autofac using the .UseAutofacContainerBuilder(...)");
            }

            return(autofacRootResolver.Container);
        }
示例#3
0
        public void Test()
        {
            IEventFlowOptions eventFlow = EventFlowOptions.New
                                          .AddDefaults(typeof(CustomerTests).Assembly);

            CustomerDefinition.Define(eventFlow);

            IRootResolver resolver = eventFlow.CreateResolver();
            ICommandBus   bus      = resolver.Resolve <ICommandBus>();

            CustomerId aggregateId = CustomerId.New;

            bus.PublishAsync(new CreateCustomer(aggregateId), CancellationToken.None);
            bus.PublishAsync(new DeleteCustomer(aggregateId), CancellationToken.None);
        }
示例#4
0
 protected override IRootResolver CreateRootResolver(IEventFlowOptions eventFlowOptions)
 {
     return(eventFlowOptions.CreateResolver(false));
 }
 protected override IRootResolver CreateRootResolver(IEventFlowOptions eventFlowOptions)
 {
     return eventFlowOptions.CreateResolver();
 }