// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <RestApiContext>(options => { //options.UseInMemoryDatabase("Test"); options.UseSqlServer(Configuration.GetConnectionString("RestApiTest")); }); // Register the Swagger generator, defining 1 or more Swagger documents services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" }); // Set the comments path for the Swagger JSON and UI. var xmlFile = $"Sdt.Practice.xml"; var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); c.IncludeXmlComments(xmlPath); }); services.AddAutoMapper(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.Configure <MvcOptions>(mvcOptions => { mvcOptions.Filters.Add(new ApiExceptionFilter()); }); ApplicationModule.Register(services); DataModule.Register(services); }
public static IServiceCollection ConfigureContainer(this IServiceCollection services, IConfiguration configuration) { DataModule.Register(services, configuration); DomainModule.Register(services); InfrastructureModule.Register(services, configuration); return(services); }
private static void InitializeContainer(Container container) { AppServiceModule.Register(container); ServiceModule.Register(container); RepositoryModule.Register(container); DataModule.Register(container); ValidatorModule.Register(container); //FluentValidationModelValidatorProvider.Configure(GlobalConfiguration.Configuration, provider => //{ // provider.ValidatorFactory = new ApplicationValidatorFactory(container); //}); }