Пример #1
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddConfigOptions <AppSettings>(Configuration, "Configuration");
     services.AddMemoryCache();
     DataServicesConfig.ConfigureDataServices(services, Configuration);
     WebServicesConfig.ConfigureWebServices(services);
     UserServicesConfig.ConfigureAppServices(services);
     ApplicationServicesConfig.ConfigureAppManagers(services);
 }
Пример #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var         appSettings    = Configuration.GetSection("AppSettings");
            AppSettings parsedSettings = new AppSettings();

            ConfigurationBinder.Bind(appSettings, parsedSettings);

            services.Configure <AppSettings>(appSettings);
            services.AddMemoryCache();
            DataServicesConfig.ConfigureDataServices(services, Configuration, parsedSettings);
            WebServicesConfig.ConfigureWebServices(services);
            UserServicesConfig.ConfigureAppServices(services);
            ManagersConfig.ConfigureAppManagers(services);
            AuthServicesConfig.ConfigJwtAuthentication(services, parsedSettings, Configuration["JWTKey"]);
        }
Пример #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //services.AddCors();
            //services.AddControllers();

            //services.AddDbContext<ApplicationDbContext>(options =>
            //{
            //    options.UseLazyLoadingProxies();
            //    options.UseSqlServer(
            //        Configuration.GetConnectionString("DefaultConnection"));
            //});

            //services.AddIdentity<User, IdentityRole>(options =>
            //    {
            //        options.Password.RequireDigit = false;
            //        options.Password.RequireLowercase = false;
            //        options.Password.RequireNonAlphanumeric = false;
            //        options.Password.RequireUppercase = false;
            //        options.Password.RequiredLength = 1;
            //    })
            //    .AddDefaultTokenProviders()
            //    .AddEntityFrameworkStores<ApplicationDbContext>();

            //var mappingConfig = new MapperConfiguration(mc =>
            //    mc.AddProfile(new MappingProfile())
            //);
            //// configure strongly typed settings objects
            //var appSettingsSection = Configuration.GetSection("AppSettings");
            ////services.Configure<AppSettings>(appSettingsSection);

            //// configure jwt authentication
            //var appSettings = appSettingsSection.Get<AppSettings>();
            //var key = Encoding.ASCII.GetBytes(appSettings.Secret);
            //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
            //        };
            //    });
            var         appSettings    = Configuration.GetSection("AppSettings");
            AppSettings parsedSettings = new AppSettings();

            ConfigurationBinder.Bind(appSettings, parsedSettings);
            services.Configure <AppSettings>(appSettings);
            services.AddMemoryCache();

            DataServicesConfig.ConfigureDataServices(services, Configuration, parsedSettings);
            WebServicesConfig.ConfigureWebServices(services);
            AuthServiceConfig.ConfigJwtAuthentication(services, parsedSettings, Configuration["JWTKey"]);


            services.AddScoped <IPageService, PageService>();
        }