public static IQueryProcessorExtensionBuilder AddDarker(this IServiceCollection services, Action <DarkerOptions> configure = null) { if (services == null) { throw new ArgumentNullException(nameof(services)); } var options = new DarkerOptions(); configure?.Invoke(options); var registry = new AspNetHandlerRegistry(services); var factory = new AspNetHandlerFactory(services); registry.RegisterFromAssemblies(options.DiscoverQueriesAndHandlersFromAssemblies); var builder = QueryProcessorBuilder.With() .Handlers(registry, factory, registry, factory) .QueryContextFactory(options.QueryContextFactory); var queryProcessor = builder.Build(); services.AddSingleton(queryProcessor); return((QueryProcessorBuilder)builder); }
public static IDarkerHandlerBuilder AddDarker(this IServiceCollection services, Action <DarkerOptions> configure = null) { if (services == null) { throw new ArgumentNullException(nameof(services)); } var options = new DarkerOptions(); configure?.Invoke(options); var registry = new AspNetHandlerRegistry(services, options.HandlerLifetime); var factory = new AspNetHandlerFactory(services); var builder = QueryProcessorBuilder.With() .Handlers(registry, factory, registry, factory) .QueryContextFactory(options.QueryContextFactory); var queryProcessor = builder.Build(); services.AddSingleton(queryProcessor); return(new AspNetHandlerBuilder(services, registry, (QueryProcessorBuilder)builder)); }