// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddDbContext <BankContext>(options => options.UseSqlServer(Configuration.GetConnectionString("BankContext"))); NativeInjectorMapping.RegisterServices(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <ApplicationDbContext>(options => options.UseSqlServer( Configuration.GetConnectionString("DefaultConnection"))); services.AddDefaultIdentity <IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true) .AddEntityFrameworkStores <ApplicationDbContext>(); services.AddControllersWithViews(); services.AddRazorPages(); NativeInjectorMapping.RegisterServices(services); }
private static void RegistersServices(IServiceCollection service) { NativeInjectorMapping.RegisterServices(service); }
public void ConfigureServices(IServiceCollection services) { services.AddCors(); services.AddControllers(); services.AddDbContext <ProjetoRcssContext>(options => options.UseSqlServer(Configuration.GetConnectionString("RcssContext"))); services.AddSwaggerGen(c => { c.SwaggerDoc(name: "v1", new OpenApiInfo { Title = "RCSS WebApi", Version = "v1" }); var definition = new OpenApiSecurityScheme { In = ParameterLocation.Header, Description = "Por favor, insira no campo a palavra 'Bearer', seguida por espaço e JWT", Name = "Authorization", Type = SecuritySchemeType.ApiKey }; c.AddSecurityDefinition("Bearer", definition); c.AddSecurityRequirement(new OpenApiSecurityRequirement() { { new OpenApiSecurityScheme { Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Bearer" }, Scheme = "oauth2", Name = "Bearer", In = ParameterLocation.Header }, new List <string>() } }); }); var key = Encoding.ASCII.GetBytes(Configuration.GetSection("Jwt").GetValue <string>("SecretKey")); services.AddAuthentication(x => { x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }) .AddJwtBearer(x => { x.RequireHttpsMetadata = false; x.SaveToken = true; x.TokenValidationParameters = new TokenValidationParameters { ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(key), ValidateIssuer = false, ValidateAudience = false }; }); NativeInjectorMapping.RegisterServices(services); }