// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //Camelcase para json services.AddMvc() .AddJsonOptions(options => { options.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver(); }); services.AddDbContext <DbContextSeed>( options => options.UseSqlServer( Configuration .GetSection("ConfigConnectionString:Default").Value)); services.AddDistributedRedisCache(options => { options.Configuration = Configuration.GetSection("RedisConnStrings:Seed").Value; options.InstanceName = "Seed"; }); services.Configure <ConfigSettingsBase>(Configuration.GetSection("ConfigSettings")); services.AddSingleton <IConfiguration>(Configuration); services.AddSingleton(new EnviromentInfo { RootPath = this._env.ContentRootPath }); // Config AuthorityEndPoint SSO services.AddAuthentication("Bearer") .AddIdentityServerAuthentication(options => { options.Authority = Configuration.GetSection("ConfigSettings:AuthorityEndPoint").Value; options.RequireHttpsMetadata = false; options.ApiName = "ssosa"; }); // Add cross-origin resource sharing services Configurations Cors.Enable(services); // Add application services. ConfigContainerSeed.Config(services); // Add framework services. services.AddMvc(options => { options.ModelBinderProviders.Insert(0, new DateTimePtBrModelBinderProvider()); }) .AddJsonOptions(options => { options.SerializerSettings.Converters.Add(new DateTimePtBrConverter()); }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //Camelcase para json services.AddMvc() .AddJsonOptions(options => { options.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver(); }); services.AddDbContext <DbContextSeed>( options => options.UseSqlServer( Configuration .GetSection("ConfigConnectionString:Default").Value)); services.AddDistributedRedisCache(options => { options.Configuration = Configuration.GetSection("RedisConnStrings:Seed").Value; options.InstanceName = "Seed"; }); services.Configure <ConfigSettingsBase>(Configuration.GetSection("ConfigSettings")); services.AddSingleton <IConfiguration>(Configuration); // Add cross-origin resource sharing services Configurations Cors.Enable(services); // Add application services. ConfigContainerSeed.Config(services); // Add framework services. services.AddMvc(options => { options.ModelBinderProviders.Insert(0, new DateTimePtBrModelBinderProvider()); }) .AddJsonOptions(options => { options.SerializerSettings.Converters.Add(new DateTimePtBrConverter()); }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //Camelcase para json services.AddMvc() .AddJsonOptions(options => { options.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver(); }); services.AddDbContext <DbContextSeed>( options => options.UseSqlServer( Configuration .GetSection("ConfigConnectionString:Default").Value)); services.AddDistributedRedisCache(options => { options.Configuration = Configuration.GetSection("RedisConnStrings:Seed").Value; options.InstanceName = "Seed"; }); services.Configure <ConfigSettingsBase>(Configuration.GetSection("ConfigSettings")); services.AddSingleton <IConfiguration>(Configuration); services.AddSingleton(new EnviromentInfo { RootPath = this._env.ContentRootPath }); // Config AuthorityEndPoint SSO services.AddAuthentication("Bearer") .AddIdentityServerAuthentication(options => { options.Authority = Configuration.GetSection("ConfigSettings:AuthorityEndPoint").Value; options.RequireHttpsMetadata = false; options.ApiName = "ssosa"; }); // Add cross-origin resource sharing services Configurations var sp = services.BuildServiceProvider(); var configuration = sp.GetService <IOptions <ConfigSettingsBase> >(); Cors.Enable(services, configuration.Value.ClientAuthorityEndPoint.ToArray()); // Add application services. ConfigContainerSeed.Config(services); // Add framework services. services.AddMvc(options => { options.ModelBinderProviders.Insert(0, new DateTimePtBrModelBinderProvider()); }) .AddJsonOptions(options => { options.SerializerSettings.Converters.Add(new DateTimePtBrConverter()); }); //Policys services.AddAuthorizationPolicy(ProfileCustom.Define); // Configurando o serviço do Swagger services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "Seed", Version = "v1", Description = "Seed", }); var caminhoAplicacao = PlatformServices.Default.Application.ApplicationBasePath; var nomeAplicacao = PlatformServices.Default.Application.ApplicationName; var caminhoXmlDoc = Path.Combine(caminhoAplicacao, $"{nomeAplicacao}.xml"); c.IncludeXmlComments(caminhoXmlDoc); c.AddSecurityDefinition("oauth2", new OAuth2Scheme { Type = "oauth2", Flow = "implicit", AuthorizationUrl = "http://localhost:4000/connect/authorize", Scopes = new Dictionary <string, string> { { "ssosa", "ssosa" }, } }); c.OperationFilter <AuthorizeCheckOperationFilter>(); }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers().AddJsonOptions(options => { options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; options.JsonSerializerOptions.IgnoreNullValues = true; options.JsonSerializerOptions.WriteIndented = false; options.JsonSerializerOptions.AllowTrailingCommas = true; options.JsonSerializerOptions.Converters.Add(new StringJsonConverter()); }); services.AddDbContext <DbContextSeed>( options => options.UseSqlServer( Configuration .GetSection("ConfigConnectionString:Default").Value)); services.AddDistributedRedisCache(options => { options.Configuration = Configuration.GetSection("ConfigCache:Default").Value; options.InstanceName = "Seed"; }); services.Configure <ConfigSettingsBase>(Configuration.GetSection("ConfigSettings")); services.Configure <ConfigStorageConnectionStringBase>(Configuration.GetSection("ConfigStorage")); services.AddSingleton <IConfiguration>(Configuration); services.AddSingleton(new EnviromentInfo { RootPath = this._env.ContentRootPath }); services.AddLogging(loggingBuilder => { loggingBuilder.AddConfiguration(Configuration.GetSection("Logging")); loggingBuilder.AddConsole(); loggingBuilder.AddDebug(); }); // Config AuthorityEndPoint SSO services.AddAuthentication("Bearer") .AddIdentityServerAuthentication(options => { options.Authority = Configuration.GetSection("ConfigSettings:AuthorityEndPoint").Value; options.RequireHttpsMetadata = false; options.ApiName = "ssosa"; }); // Add cross-origin resource sharing services Configurations var sp = services.BuildServiceProvider(); var configuration = sp.GetService <IOptions <ConfigSettingsBase> >(); Cors.Enable(services, configuration.Value.ClientAuthorityEndPoint.ToArray()); services.AddAutoMapper(AutoMapperConfigSeed.RegisterMappings()); // Add application services. ConfigContainerSeed.Config(services); // Add framework services. //services.AddMvc(options => //{ // options.ModelBinderProviders.Insert(0, new DateTimePtBrModelBinderProvider()); // options.ModelBinderProviders.Insert(1, new NumberModelBinderProvider()); //}); //.AddNewtonsoftJson(); // TODO : MIGRAÇÃO PROBLEMA 02 //.AddJsonOptions(options => //{ // options.SerializerSettings.Converters.Add(new DateTimePtBrConverter()); // options.SerializerSettings.Converters.Add(new DecimalPtBrConverter()); //}); //Policys services.AddAuthorizationPolicy(ProfileCustom.Define); // Configurando o serviço do Swagger //services.AddSwaggerGen(c => //{ // c.SwaggerDoc("v1", // new Info // { // Title = "Target.Intranet", // Version = "v1", // Description = "Target.Intranet", // }); // var caminhoAplicacao = PlatformServices.Default.Application.ApplicationBasePath; // var nomeAplicacao = PlatformServices.Default.Application.ApplicationName; // var caminhoXmlDoc = Path.Combine(caminhoAplicacao, $"{nomeAplicacao}.xml"); // c.IncludeXmlComments(caminhoXmlDoc); // c.AddSecurityDefinition("oauth2", new OAuth2Scheme // { // Type = "oauth2", // Flow = "implicit", // AuthorizationUrl = "http://localhost:4000/connect/authorize", // Scopes = new Dictionary<string, string> // { // { "ssosa", "ssosa" }, // } // }); // c.OperationFilter<AuthorizeCheckOperationFilter>(); //}); }