// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { BaseApiStartupSetup.AddCommonServices(services); BaseApiStartupSetup.AddSwagger(services, "v1.0", "ProposalsAPI", "WealthTools.WebAPI.Proposals"); BaseApiStartupSetup.AddAuthorization(services, Configuration); BaseApiStartupSetup.AddHealthCheck(services, Configuration, new List <HealthCheck>() { HealthCheck.OracleConnection, HealthCheck.Redis }); var sp = services.BuildServiceProvider(); //AddProtectionService(services, Configuration, sp); BaseApiStartupSetup.AddProtectionService(services, Configuration, sp); // Add Project Specific Packages services.AddScoped <IProposalsRepository, ProposalsRepository>(); services.AddScoped <IAccountsRepository, AccountsRepository>(); services.AddScoped <IBrokerMgrRepository, BrokerMgrRepository>(); services.AddScoped <IContactsRepository, ContactsRepository>(); services.AddScoped <ISearchRepository, SearchRepository>(); //Reports services.AddScoped <IReportManager, ReportManager>(); services.AddScoped <IReportFactory, ProposalsReportFactory>(); services.AddScoped <IReportsRepository, ReportsRepository>(); #region Individual Report Classes services.AddTransient <CoverPage>(); #endregion //Reports }
//public static void AddProtectionService(IServiceCollection services, IConfiguration configuration, IServiceProvider serviceProvider) //{ // var configSection = configuration.GetSection("ProtectionServicesConfig"); // if (configSection != null) // { // if (configSection["Unprotect"] != "true") // { // //Add the helper so its availble for all classes. // string Key = configSection["EncKey"]; // var ihelper = serviceProvider.GetRequiredService<IEncrypt>(); // EncryptHelper encryptHelper = new EncryptHelper(ihelper, Key); // // services.AddScoped<IEncrtpyHelper, EncryptHelper>(s => new EncryptHelper(s.GetRequiredService<IEncrypt>(), Key)); // services.AddSingleton<IEncrtpyHelper, EncryptHelper>(s => new EncryptHelper(ihelper, Key)); // var sp = services.BuildServiceProvider(); // services.AddMvc().AddJsonOptions(opt => // { // opt.SerializerSettings.ContractResolver = new ProtectedStringPropertyResolverX(sp) { }; // }); // } // } //} // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IHttpContextAccessor accessor, IWMLogger logger) { BaseApiStartupSetup.UseHealthChecks(app); BaseApiStartupSetup.UseExceptionHandler(app, env, logger, "ProposalsAPI"); BaseApiStartupSetup.UseCors(app); BaseApiStartupSetup.UseSwagger(app, "../swagger/v1.0/swagger.json", "WealthTools.WebAPI.Proposals v1.0"); app.UseAuthentication(); // app.UseWealthToolsUsage(); //app.UseHttpsRedirection(); app.UseMvc(); }