// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDistributedMemoryCache(); services.AddSession(options => { options.IdleTimeout = TimeSpan.FromSeconds(10); options.Cookie.HttpOnly = true; options.Cookie.IsEssential = true; }); // CONFIGURAÇÃO DA CONEXÃO COM O DB E O CONTEXT var connection = Configuration["ConexaoSqlite:SqliteConnectionString"]; ConfigureContext <MyContext> .Configure(services, connection); // CONFIGURAÇÃO DA INJEÇÃO DE DEPENDÊNCIA ConfigureDependencyInjection.Configuration(services); services.AddControllers().AddNewtonsoftJson(options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore ); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddControllersWithViews(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { ConfigureContext.AddDbContexts(services); services.AddScoped <IMemberService, MemberService>(); services.AddControllers(); }
public void ConfigureServices(IServiceCollection services) { ConfigureContext.ConfigureContextDependencies(services); ConfigureTransaction.ConfigureTransactionDependencies(services); ConfigureRepository.ConfigureRepositoryDependencies(services); ConfigureService.ConfigureServiceDependencies(services); services.AddControllers(); }
public virtual MainApplicationContext CreateContext(MemoryStreamManager memoryStreamManager) { var context = new MainApplicationContext(CreateApplicationServiceProvider(memoryStreamManager)); context.IsAtty = false; ConfigureContext?.Invoke(context); return(context); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { ConfigureContext.ConfigureDependencyInjector(services); ConfigureRepository.ConfigureDependencyInjector(services); ConfigureService.ConfigureDependencyInjector(services); ConfigureSecurity.ConfigureJwtToken(services, Configuration); ConfigureSwagger(services); ConfigureMapping(services); services.AddControllers(); }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); ConfigureContext.Configure(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //Configure Localization services.AddLocalization(options => options.ResourcesPath = "Resources"); services.Configure <RequestLocalizationOptions>(options => { var cultureInfoList = new List <CultureInfo> { new CultureInfo("en"), new CultureInfo("ar") }; options.DefaultRequestCulture = new RequestCulture("ar", "ar"); options.SupportedCultures = cultureInfoList; options.SupportedUICultures = cultureInfoList; }); //Configure Database connections // ConfigureConnectionOptions.ConfigureService(services, Configuration); //Use a MS SQL Server database // var sqlConnectionString = Configuration.GetConnectionString("StudentSqlDB"); // // services.AddDbContextPool<StudentDBContext>(options => // services.AddDbContext<StudentDBContext>(options => // options.UseSqlServer( // sqlConnectionString, // b => b.MigrationsAssembly("StudentApi") // ) //); //Configure Database Context ConfigureContext.ConfigureService(services, Configuration); //Configure Student Container ConfigureStudentContainer.ConfigureService(services, Configuration); //Configure Student Aysnc Container ConfigureStudentContainerAsync.ConfigureService(services, Configuration); //services.AddLogging((builder) => builder.SetMinimumLevel(LogLevel.Trace)); //.AddFluentValidation(); //.AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining<Startup>()); //services.AddScoped<IStudentGeneralService, StudentGeneralService>(); //services.AddScoped<IStudentGeneralServiceAsync, StudentGeneralServiceAsync>(); //services.AddScoped<IUnitOfWork, UnitOfWork<StudentDBContext>>(); //services.AddScoped<IEntityReadStudentGeneralRepository, EntityReadStudentGeneralRepository>(); //services.AddScoped<IEntityStudentGeneralRepository, EntityStudentGeneralRepository>(); //services.AddScoped<IEntityReadStudentGeneralRepositoryAsync, EntityReadStudentGeneralRepositoryAsync>(); //services.AddScoped<IEntityStudentGeneralRepositoryAsync, EntityStudentGeneralRepositoryAsync>(); //add fluent validation scope services.AddScoped <IValidator <StudentGeneralModel>, StudentGeneralModelValidator>(); //Add MVC To Service services.AddMvc(); //Add Swagger To Service //services.AddSwaggerGen(c => //{ // c.SwaggerDoc("v1", new Info { Title = "Student API", Version = "v1" }); //}); //Add Auto Mapper services.AddAutoMapper(); //services.AddScoped<LoggingActionFilter>(); }