Exemplo n.º 1
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.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            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(Encoding.ASCII.GetBytes("b63ad5ec-61fb-493a-a03f-887bf691b690")),
                    ValidateIssuer           = false,
                    ValidateAudience         = false
                };
            });

            StorageRegistrator.RegisterStorage(services, Configuration);

            services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());

            services.Configure <AppSettings>(options => Configuration.GetSection("AppSettings").Bind(options));
            var appSettings = services.BuildServiceProvider().GetService <IOptions <AppSettings> >().Value;

            services.AddSingleton(appSettings);

            services.AddScoped <IAdminUserService, AdminUserService>();
            services.AddScoped <IOrderService, OrderService>();
            services.AddScoped <IGemstoneService, GemstoneService>();
            services.AddScoped <IColorService, ColorService>();
            services.AddScoped <IMetalService, MetalService>();
            services.AddScoped <ICache, Cache>();
            services.AddScoped <IParsedModelCache, ParsedModelCache>();
            services.AddScoped <ICatalogModelsCache, CatalogModelsCache>();
            services.AddScoped <IJewelryModelService, JewelryModelService>();
            services.AddScoped <IModelInfoCache, ModelInfoCache>();
            services.AddScoped <ISkuDescriptionService, SkuDescriptionService>();
            services.AddScoped <SiteMapModelService>();
            services.AddScoped <ModelParser>();
            services.AddScoped <VariablesEvaluator>();
            services.AddScoped <ExpressionCalculatorService>();

            // In production, the Angular files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/dist";
            });
        }
Exemplo n.º 2
0
        // 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_2);

            // In production, the Angular files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/dist";
            });

            services.AddHttpsRedirection(options =>
            {
                options.HttpsPort = 443;
            });

            services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
            services.AddMemoryCache();

            services.Configure <AppSettings>(options => Configuration.GetSection("AppSettings").Bind(options));
            var appSettings = services.BuildServiceProvider().GetService <IOptions <AppSettings> >().Value;

            services.AddSingleton(appSettings);

            StorageRegistrator.RegisterStorage(services, Configuration);

            services.AddSingleton(appSettings);
            services.AddScoped <ICache, Cache>();
            services.AddScoped <IModelInfoCache, ModelInfoCache>();
            services.AddScoped <IParsedModelCache, ParsedModelCache>();
            services.AddScoped <ICatalogModelsCache, CatalogModelsCache>();
            services.AddScoped <IJewelryModelService, JewelryModelService>();
            services.AddScoped <IModelImageService, ModelImageService>();
            services.AddScoped <ISkuDescriptionService, SkuDescriptionService>();
            services.AddScoped <IOrderService, OrderService>();
            if (appSettings.MailSettings.SmtpSettings.Host == "localhost")
            {
                services.AddScoped <IMailSender, DummyMailSender>();
            }
            else
            {
                services.AddScoped <IMailSender, MailSender>();
            }
            services.AddScoped <ModelParser>();
            services.AddScoped <VariablesEvaluator>();
            services.AddScoped <ExpressionCalculatorService>();
            services.AddScoped <SiteMapModelService>();
        }