コード例 #1
0
        // 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();
        }
コード例 #2
0
ファイル: Startup.cs プロジェクト: thomaspet/BotBackend
        // 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();
        }
コード例 #3
0
 public void ConfigureServices(IServiceCollection services)
 {
     ConfigureContext.ConfigureContextDependencies(services);
     ConfigureTransaction.ConfigureTransactionDependencies(services);
     ConfigureRepository.ConfigureRepositoryDependencies(services);
     ConfigureService.ConfigureServiceDependencies(services);
     services.AddControllers();
 }
コード例 #4
0
        public virtual MainApplicationContext CreateContext(MemoryStreamManager memoryStreamManager)
        {
            var context = new MainApplicationContext(CreateApplicationServiceProvider(memoryStreamManager));

            context.IsAtty = false;

            ConfigureContext?.Invoke(context);

            return(context);
        }
コード例 #5
0
ファイル: Startup.cs プロジェクト: joasimonson/AspNetCore
        // 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();
        }
コード例 #6
0
ファイル: Startup.cs プロジェクト: bh-schmidt/ef-crud
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            ConfigureContext.Configure();
        }
コード例 #7
0
        // 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>();
        }