Пример #1
0
        private async Task ExecuteMiddlewareAsync(CommandContext context, IModuleCache moduleCache)
        {
            var services = new ServiceCollection();

            services.AddLogging();

            services.AddSingleton <IModuleCache>(moduleCache);

            var provider = services.BuildServiceProvider(true);

            context.ServiceScopeFactory = provider.GetRequiredService <IServiceScopeFactory>();

            var app = new TestCommandApplicationBuilder(provider);

            app.UseStringMatcher();

            var commandDelegate = app.Build();

            await commandDelegate(context);
        }
 public ModuleContainer(IModuleCache cache, IModuleFactory factory)
 {
     moduleCache   = cache;
     moduleFactory = factory;
 }
Пример #3
0
 public CommandStringMatcherMiddleware(IModuleCache moduleCache, ILogger <CommandStringMatcherMiddleware> logger)
 {
     _moduleCache = moduleCache;
     _logger      = logger;
 }
 /// <summary>
 /// Creates a new instance of <see cref="ModuleConfigurer" />
 /// </summary>
 /// <param name="options">The current command app options.</param>
 /// <param name="moduleCache">The module cache to save the added modules.</param>
 /// <param name="moduleFactory">The factory to create modules.</param>
 public ModuleConfigurer(IOptions <MariCommandsOptions> options, IModuleCache moduleCache, IModuleFactory moduleFactory)
 {
     Options        = options.Value;
     _moduleCache   = moduleCache;
     _moduleFactory = moduleFactory;
 }