private async Task ExecuteMiddlewareAsync(CommandContext context, MariCommandsOptions config = null, bool addFilter = false) { var services = new ServiceCollection(); services.AddLogging(); if (config.HasContent()) { services.AddSingleton <IOptions <MariCommandsOptions> >(config); } else { services.AddOptions <MariCommandsOptions>(); } services.AddSingleton <IFilterProvider, FilterProvider>(); if (addFilter) { services.AddFilterFactory <ResultFilterFactory, ICommandResultFilter, CommandResultDelegate>(); services.AddSingleton <SingletonDependency>(); } var provider = services.BuildServiceProvider(true); context.ServiceScopeFactory = provider.GetRequiredService <IServiceScopeFactory>(); var app = new TestCommandApplicationBuilder(provider); app.UseCommandExecutor(); var commandDelegate = app.Build(); await commandDelegate(context); }
private async Task ExecuteMiddlewareAsync(CommandContext context, MariCommandsOptions config = null) { var services = new ServiceCollection(); services.AddLogging(); if (config.HasContent()) { services.AddSingleton <IOptions <MariCommandsOptions> >(config); } else { services.AddOptions <MariCommandsOptions>(); } var provider = services.BuildServiceProvider(true); context.ServiceScopeFactory = provider.GetRequiredService <IServiceScopeFactory>(); var app = new TestCommandApplicationBuilder(provider); app.UseInputCountMatcher(); var commandDelegate = app.Build(); await commandDelegate(context); }