// 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); services.AddCors(options => { options.AddPolicy("CorsPolicy", builder => builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); }); services.AddAuthentication(options => { options.DefaultAuthenticateScheme = "JwtBearer"; options.DefaultChallengeScheme = "JwtBearer"; } ).AddJwtBearer("JwtBearer", options => { //Define as opções options.TokenValidationParameters = new TokenValidationParameters { //Quem esta solicitando ValidateIssuer = true, //Quem esta validadando ValidateAudience = true, //Definindo o tempo de expiração ValidateLifetime = true, //Forma de criptografia IssuerSigningKey = new SymmetricSecurityKey(System.Text.Encoding.UTF8.GetBytes("corujasdev-schedule-key-auth")), //Tempo de expiração do Token ClockSkew = TimeSpan.FromMinutes(30), //Nome da Issuer, de onde esta vindo ValidIssuer = "CorujasDev.Schedule", //Nome da Audience, de onde esta vindo ValidAudience = "CorujasDev.Schedule" }; }); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "CorujasDev Schedule Web API", Version = "v1" }); }); services.AddAutoMapperSetup(); DCCodeFirst.CreateDatabaseIfNotExistsAsync(); DCCodeFirst.CreateDocumentCollectionIfNotExistsAsync(); NativeInjectorConfig.RegisterServices(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { NativeInjectorConfig.RegisterServices(services); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "RickLocalization API", Version = "v1" }); }); services.AddControllers(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { NativeInjectorConfig.RegisterServices(services); services.AddCouchbase(Configuration.GetSection("Couchbase")); services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <CadastroProdutoContext>(o => o.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); services.Configure <CookiePolicyOptions>(options => { options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddSwaggerGen(s => { s.SwaggerDoc("v1", new OpenApiInfo { Version = "v1", Title = "API Cadastro Produto", Description = "API Cadastro Produto - Swagger", }); }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0); services.AddAutoMapperSetup(); services.AddMediatRSetup(); services.Configure <FormOptions>(o => { o.ValueLengthLimit = int.MaxValue; o.MultipartBodyLengthLimit = int.MaxValue; o.MemoryBufferThreshold = int.MaxValue; }); NativeInjectorConfig.RegisterServices(services); services.AddControllersWithViews(); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddDbContext <ApplicationDbContext>(options => options.UseSqlite( Configuration.GetConnectionString("DefaultConnection"))); services.AddDefaultIdentity <IdentityUser>() .AddDefaultUI(UIFramework.Bootstrap4) .AddEntityFrameworkStores <ApplicationDbContext>(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddAutoMapperSetup(); services.AddMediatRSetup(); NativeInjectorConfig.RegisterServices(services); }
private static void RegisterServices(IServiceCollection services) { // Adding dependencies from another layers (isolated from Presentation) NativeInjectorConfig.RegisterServices(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "BRQ - HRT", Version = "v1.1" }); }); // String de conexão que o OData utilizará Ao fazer suas Queries var conexao = "Data Source = brqsenai.database.windows.net; Initial Catalog = hrt_database; User ID = brqsenai; Password = @Senai132"; services.AddMvc() .SetCompatibilityVersion(CompatibilityVersion.Version_2_1) .AddJsonOptions(options => { options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; }); // Devemos Criar o contexto antes de descomentar o codigo abaixo services.AddDbContext <ContextoHRT>(options => { options.UseSqlServer(conexao); }); services.AddOData(); // O forEach é responsavel para mapear e dar suporte ao OData no swagger services.AddMvcCore(options => { foreach (var outputFormatter in options.OutputFormatters.OfType <ODataOutputFormatter>().Where(_ => _.SupportedMediaTypes.Count == 0)) { outputFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/prs.odatatestxx-odata")); } foreach (var inputFormatter in options.InputFormatters.OfType <ODataInputFormatter>().Where(_ => _.SupportedMediaTypes.Count == 0)) { inputFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/prs.odatatestxx-odata")); } }); // Serviço de autenticação (Utilizado na parte "login"(Matricula)) services.AddAuthentication(options => { options.DefaultAuthenticateScheme = "JwtBearer"; options.DefaultChallengeScheme = "JwtBearer"; }).AddJwtBearer("JwtBearer", options => { options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = true, ValidateAudience = true, ValidateLifetime = true, IssuerSigningKey = new SymmetricSecurityKey(System.Text.Encoding.UTF8.GetBytes("L*rKP-x#Fl7-NayO@-Xd!9b")), ClockSkew = TimeSpan.FromHours(2), ValidIssuer = "HTR.WebApi", ValidAudience = "HTR.WebApi" }; }); // Adiciona a politica do Cors services.AddCors(options => { options.AddPolicy("CorsPolicy", builder => builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); }); // controla a injeção de dependencias no sistema NativeInjectorConfig.RegisterServices(services); // Adiciona a configuração do auto mapper services.AddAutoMapperSetup(); }
private static void RegisterServices(IServiceCollection services) { NativeInjectorConfig.RegisterServices(services); }