// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "Mock Generator", Version = "v1" }); }); Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); services.AddMvc().AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver()); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1) .AddJsonOptions(opcoes => { opcoes.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore; }); InjecaoDependencia.Configurar(Configuration, services); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); InjecaoDependencia.InstanciarRepositorios(_services, serviceProvider, Configuration); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); //setup para configuração Swagger.. SwaggerSetup.AddSwaggerSetup(services); //setup para configuração do EntityFramework.. EntityFrameworkSetup.AddEntityFrameworkSetup(services, Configuration); //setup para configuração de injeção de dependencia.. InjecaoDependencia.Registrar(services); //setup para JWT Bearer.. JwtBearerSetup.AddJwtBearerSetup(services, Configuration); //setup para MongoDB.. MongoDBSetup.AddMongoDBSetup(services, Configuration); //setup para MediatR.. MediatRSetup.AddMediatRSetup(services); //setup para AutoMapper.. AutoMapperSetup.AddAutoMapperSetup(services); //Setup para o Cors CorsSetup.AddCorsSetup(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { _services = services; InjecaoDependencia.AdicionarContexto(services, Configuration); //services.AddDbContext<DatabaseContext>(options => // options.UseSqlServer(Configuration.GetConnectionString("TesteConsultoriaTaking"))); services.AddControllers().AddJsonOptions(jsonOptions => { jsonOptions.JsonSerializerOptions.IgnoreNullValues = true; }); services.Configure <ApiBehaviorOptions>(options => { options.SuppressModelStateInvalidFilter = true; }); InjecaoDependencia.InjetarRepositorios(services); }
private static void RegisterServices(IServiceCollection services) { InjecaoDependencia.RegisterServices(services); }
public static void StartUp(TestContext testContext) { services = new ServiceCollection(); InjecaoDependencia.Start(services); provider = services.BuildServiceProvider(); }