// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddAuthentication("Bearer").AddIdentityServerAuthentication(options => { options.Authority = "http://localhost:5000"; options.RequireHttpsMetadata = false; options.ApiName = "bankOfDotNetApi"; }); services.AddDbContext <BankContext>(opts => opts.UseInMemoryDatabase("BankingDb")); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); SwaggerInstaller.IInstallServices(Configuration, services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var db = new DbInstaller(); db.InstallServices(services, Configuration); var mvc = new MvcInstaller(); mvc.InstallServices(services, Configuration); services.AddAutoMapper(typeof(Startup)); var swagger = new SwaggerInstaller(); swagger.InstallServices(services, Configuration); var cache = new CacheInstaller(); cache.InstallServices(services, Configuration); }
public virtual Installers Build(Type startupType, IConfiguration configuration) { var installers = new Installers(); installers.Add(new HeaderForwardingInstaller()); var healthCheck = HealthCheckInstaller.FromConfiguration(configuration); if (healthCheck != null) { installers.Add(healthCheck); } installers.Add(new RequestLoggingInstaller()); var swagger = SwaggerInstaller.FromConfiguration(installers, configuration, startupType); if (swagger != null) { installers.Add(swagger); } return(installers); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <SecurityContext>(options => options.UseSqlServer( Configuration["ConnectionStrings:SecurityContextConnection"])); services.AddMvc(options => { options.EnableEndpointRouting = false; options.Filters.Add <ValidationFilter>(); }) .SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_3_0); // Helpers IdentityInstaller.ConfigureService(services); AuthenticationInstaller.ConfigureService(services, Configuration); SwaggerInstaller.ConfigureService(services); // Settings services.Configure <EmailSettings>(Configuration.GetSection("Email")); services.Configure <ClientAppSettings>(Configuration.GetSection("ClientApp")); services.Configure <JwtSecurityTokenSettings>(Configuration.GetSection("JwtSecurityToken")); services.Configure <QRCodeSettings>(Configuration.GetSection("QRCode")); // Services services.AddTransient <IEmailService, EmailService>(); services.AddTransient <IAuthService, AuthService>(); services.AddTransient <IUserService, UserService>(); // Data services.AddDbContextPool <DataContext>(options => options.UseSqlServer(Configuration["ConnectionStrings:DataContextConnection"], x => x.UseNetTopologySuite())); services.AddHttpContextAccessor(); services.AddControllers(); }