// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime appLifetime) { var cultureInfo = new CultureInfo("es-CO"); CultureInfo.DefaultThreadCurrentCulture = cultureInfo; CultureInfo.DefaultThreadCurrentUICulture = cultureInfo; if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseCors("CorsPolicy"); app.UseAuthentication(); app.UseSession(); SwaggerHandler.UseSwagger(app); app.UseDeveloperExceptionPage(); app.UseMvc(); appLifetime.ApplicationStarted.Register(() => { }); appLifetime.ApplicationStopped.Register(() => { }); }
public void SetUp() { _mockDiscoverer = new Mock <ISwaggerDiscoverer>(); _mockDiscoverer.Setup(x => x.ExcludedHandlers).Returns(new List <Type>()); _handler = new SwaggerHandler { Discoverer = _mockDiscoverer.Object, ExcludedHandlers = new List <Type>() }; }
//services.AddMvc().AddXmlSerializerFormatters(); // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); IConfigurationSection jwtAppSettings = Configuration.GetSection("Jwt"); services.Configure <JwtSetting>(jwtAppSettings); services.AddCors(options => { options.AddPolicy("CorsPolicy", p => p.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); }); services.AddDistributedMemoryCache(); services.AddSession(); #region Swagger Configuration SwaggerHandler.SwaggerConfig(services); services.AddApiVersioning(); #endregion Swagger Configuration //#region Jwt Configuration //JwtConfigurationHandler.ConfigureJwtAuthentication(services, jwtAppSettings); //#endregion Jwt Configuration #region Context SQL Server services.AddDbContext <Infraestructure.Core.Context.SQLServer.ContextSql>(options => options.UseSqlServer(Configuration.GetConnectionString("ConnectionStringSQLServer"), providerOptions => providerOptions.EnableRetryOnFailure())); #endregion Context SQL Server #region Register (dependency injection) DependencyInyectionHandler.DependencyInyectionConfig(services); #endregion Register (dependency injection) #region Job #endregion }
public void SetUp() { _jsonHandler = new JsonHandler(); _swaggerHandler = new SwaggerHandler(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); IConfigurationSection jwtAppSettings = Configuration.GetSection("Jwt"); services.Configure <JwtSetting>(jwtAppSettings); services.AddCors(options => { options.AddPolicy("CorsPolicy", p => p.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); }); services.AddDistributedMemoryCache(); services.AddSession(); #region Swagger Configuration SwaggerHandler.SwaggerConfig(services); #endregion #region Jwt Configuration JwtConfigurationHandler.ConfigureJwtAuthentication(services, jwtAppSettings); #endregion #region Context #region Oracle services.AddDbContext <Infraestructure.Core.Context.Context>(options => options.UseOracle(Configuration.GetConnectionString("ConnectionStringOracle"))); #endregion //#region SQL //services.AddEntityFrameworkSqlServer() // .AddDbContext<Infraestructure.Core.Context.Context>(options => // { // options.UseSqlServer(Configuration.GetConnectionString("ConnectionStringSQLServer"), // sqlOptions => sqlOptions.MigrationsAssembly(typeof(Startup) // .GetTypeInfo() // .Assembly.GetName().Name)); // }, // ServiceLifetime.Scoped); //#endregion #endregion #region Register (dependency injection) DependencyInyectionHandler.DependencyInyectionConfig(services); #endregion ////#region Job ////// Add Quartz services singleton //services.AddSingleton<IJobFactory, JobFactory>(); //services.AddSingleton<ISchedulerFactory, StdSchedulerFactory>(); //// Add our job //// services.AddSingleton<Job>(); //services.AddSingleton<Job>(); //services.AddSingleton(new JobScheduleModel( // jobType: typeof(Job), // cronExpression: "0/20 * * * * ?")); // run every 5 seconds // // 0/10 * * * * ? * run every 10 seconds //// Configure job actions //services.AddHostedService<HostedService>(); ////#endregion }