// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public virtual void ConfigureServices(IServiceCollection services) { _swagger.ConfigureServices(services); services.AddSingleton <ICustomerService, CustomerService>(); services.AddMvc(config => { config.RespectBrowserAcceptHeader = true; config.InputFormatters.Add(new XmlSerializerInputFormatter(config)); config.OutputFormatters.Add(new XmlSerializerOutputFormatter()); }).SetCompatibilityVersion(CompatibilityVersion.Version_2_1); }
// 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_1); //Paging.ConfigureServices(services); SwaggerConfig.ConfigureServices(services); AppIDConfigUrl.ConfigureServices(services); //IMapperConfig.ImapperConfigService(services); //ConfigServiceFluentValidation.ConfigureServices(services); services.AddDbContext <ChoThueXeContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); RepositoryConfig.ConfigureServices(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc(options => { options.Filters.Add(new CustomExceptionFilter()); }) .AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining <BlogDto>()) .SetCompatibilityVersion(CompatibilityVersion.Version_2_1); SwaggerConfig.ConfigureServices(services); SimpleInjectorConfig.ConfigureServices(services); services.AddLogging(); }
// This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { services .AddCustomOptions(this.Configuration) .AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); Dependencies.Register(services, this.Configuration); SwaggerConfig.ConfigureServices(services); var container = new ContainerBuilder(); container.Populate(services); return(new AutofacServiceProvider(container.Build())); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc(options => { options.Filters.Add(new CustomExceptionFilter()); }) .AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining <BlogDto>()) .SetCompatibilityVersion(CompatibilityVersion.Version_2_1); SwaggerConfig.ConfigureServices(services); SimpleInjectorConfig.ConfigureServices(services); services.AddLogging(); services.AddDbContext <AppDbContext>(options => //options.UseSqlServer(Configuration.GetConnectionString("AppDbContext"), b => b.MigrationsAssembly("CoreWebApi.Api")) options.UseInMemoryDatabase("CoreWebApi") ); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Add framework services. services.AddDbContext <CoreDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); _swagger.ConfigureServices(services); services.AddIdentity <ApplicationUser, IdentityRole>(options => { #if DEBUG options.Password.RequireDigit = false; options.Password.RequiredLength = 6; options.Password.RequireLowercase = false; options.Password.RequireNonAlphanumeric = false; options.Password.RequireUppercase = false; #endif }).AddEntityFrameworkStores <CoreDbContext>() .AddDefaultTokenProviders(); services.AddControllersWithViews(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { JwtConfig.ConfigureServices(services, this.AuthConfiguration); // Add framework services. services.AddMvc(config => { config.ModelBinderProviders.Insert(0, new WebApiPagedModelBinderProvider()); if (this.AuthConfiguration?.IsEnabled == true) { var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); config.Filters.Add(new AuthorizeFilter(policy)); } }); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddSingleton <IConfiguration>(this.Configuration); // Add CORS services services.AddCors(); // Add Koa services var businessPointerTipe = typeof(BusinessPointer); var bussinessAssembly = businessPointerTipe.GetTypeInfo().Assembly; services.AddDateTimeProvider(); services.AddIdentityProvider(); services.UseKoaEntityFramework <DataContext>(bussinessAssembly, opt => opt.UseInMemoryDatabase("DefaultDatabase")); services.UseKoaAutomaper(bussinessAssembly); services.AddHttpContextDependencies(); // Add Swagger services SwaggerConfig.ConfigureServices(services, this.SwaggerConfiguration, this.AuthConfiguration); //Add ServiceBusQueue services if (this.ServiceBusQueueConfiguration?.IsEnabled == true) { ServiceBusQueueConfig.ConfigureServices(services, this.ServiceBusQueueConfiguration); } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { CORSConfig.ConfigureServices(services); services.AddMvcCore() .AddAuthorization() .AddJsonFormatters(); services.AddAuthentication("Bearer") .AddIdentityServerAuthentication(options => { options.Authority = endponit + tenantId; options.RequireHttpsMetadata = false; }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); Paging.ConfigureServices(services); SwaggerConfig.ConfigureServices(services); AppIDConfigUrl.ConfigureServices(services); services.AddDbContext <ChoThueXeContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); RepositoryConfig.ConfigureServices(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { FilterConfig.ConfigureServices(services); DependencyInjectionResolver.ConfigureServices(services); JsonFormatConfig.ConfigureServices(services); SwaggerConfig.ConfigureServices(services); AutoMapperConfig.ConfigureServices(services); AuthConfig.ConfigureServices(services); DbConfig.ConfigureServices(services, Configuration); //sql connection services.AddRouting(options => options.LowercaseUrls = true); services.AddControllers(); CorsConfig.ConfigureServices(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { JwtConfig.ConfigureServices(services, this.AuthConfiguration); #region Allow-Orgin services.AddCors(c => { c.AddPolicy("AllowOrigin", options => options.AllowAnyOrigin()); }); #endregion services.AddControllers(); // Fluent Validation services.AddMvc(options => { options.Filters.Add(new ValidationFilter()); }).AddFluentValidation(options => { options.RegisterValidatorsFromAssemblyContaining <UserDTO>(); }); // Add API Versioning to as service to your project services.AddApiVersioning(config => { // Specify the default API Version as 1.0 config.DefaultApiVersion = new ApiVersion(1, 0); // If the client hasn't specified the API version in the request, use the default API version number config.AssumeDefaultVersionWhenUnspecified = true; // Advertise the API versions supported for the particular endpoint config.ReportApiVersions = true; // Supporting multiple versioning scheme config.ApiVersionReader = ApiVersionReader.Combine(new HeaderApiVersionReader("X-version"), new QueryStringApiVersionReader("api-version")); }); // Add Swagger services SwaggerConfig.ConfigureServices(services, this.AuthConfiguration, this.ApiMetadata); }
// This method gets called by a runtime. // Use this method to add services to the container public void ConfigureServices(IServiceCollection services) { services.AddMvc(); SwaggerConfig.ConfigureServices(services); }
// 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_1); SwaggerConfig.ConfigureServices(services); }