public static void AddWaf( this IServiceCollection services, WafHostEnum wafHost, AssemblyName[] appActionAssemblyNames, AssemblyName[] appManagerAssemblyNames) { // memory cache services.AddMemoryCache(); // register managers var managerRegistrar = new WafManagerRegistrar(); services.AddSingleton <WafManagerRegistrar>(managerRegistrar); managerRegistrar.InitializeManagers(services, appManagerAssemblyNames); // register actions var actionProcessor = new WafActionProcessor(); services.AddSingleton <WafActionProcessor>(actionProcessor); actionProcessor.InitializeActions(services, appActionAssemblyNames); if (wafHost == WafHostEnum.Web) { // current user services.AddCurrentUserForWebHost(); // routing services for web API var actionWebProcessor = new WafActionWebProcessor(actionProcessor); services.AddSingleton <WafActionWebProcessor>(actionWebProcessor); actionWebProcessor.AddRouting(services); } }
public static void AddKioskBrainsApplication( this IServiceCollection services, WafHostEnum wafHost, IConfiguration configuration) { Assure.ArgumentNotNull(configuration, nameof(configuration)); JsonDefaultSettings.Initialize(); // Settings services.Configure <EkSearchSettings>(configuration.GetSection("EkSearchSettings")); // Memory Cache services.AddMemoryCache(); // Persistent Cache services.AddScoped <IPersistentCache, DbPersistentCache>(); // DB Context services.AddDbContextPool <KioskBrainsContext>(options => options .UseSqlServer(configuration.GetConnectionString("KioskBrainsContext")) .ConfigureWarnings(warnings => warnings.Throw(RelationalEventId.QueryClientEvaluationWarning))); if (wafHost == WafHostEnum.Web) { // Authentication services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = true, ValidIssuer = JwtAuthOptions.Issuer, ValidateAudience = true, ValidAudience = JwtAuthOptions.Audience, ValidateLifetime = true, ValidateIssuerSigningKey = true, IssuerSigningKey = JwtAuthOptions.GetSymmetricSecurityKey(), }; }); // Add CurrentUser services.AddCurrentUser(); } // WAF services.AddWaf( wafHost, appActionAssemblyNames: AppActionAssemblyNames, appManagerAssemblyNames: AppActionAssemblyNames); // Integration Log services.AddTransient <IIntegrationLogManager, IntegrationLogManager>(); // Notifications services.Configure <NotificationManagerSettings>(configuration.GetSection("NotificationManagerSettings")); services.AddScoped <INotificationManager, NotificationManagerStub>(); //Repo and services services.AddScoped <ITranslateService, TranslateService>(); services.AddScoped <IReadOnlyRepository, ReadOnlyRepository <KioskBrainsContext> >(); services.AddScoped <IWriteOnlyRepository, WriteOnlyRepository <KioskBrainsContext> >(); // Common Clients services.Configure <KioskProxyClientSettings>(configuration.GetSection("KioskProxyClientSettings")); services.AddScoped <KioskProxyClient>(); services.Configure <AzureStorageSettings>(configuration.GetSection("AzureStorageSettings")); services.AddScoped <AzureStorageClient>(); }