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); }
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); }
protected override IRootResolver CreateRootResolver(IEventFlowOptions eventFlowOptions) { return(eventFlowOptions.CreateResolver(false)); }
protected override IRootResolver CreateRootResolver(IEventFlowOptions eventFlowOptions) { return eventFlowOptions.CreateResolver(); }