Beispiel #1
0
 public static string GetProductBlockTemplateFullPath(this IHostingEnvironment env)
 {
     if (string.IsNullOrEmpty(productBlockTemplateFullPath))
     {
         productBlockTemplateFullPath = $"{env.GetConfigsFolderFullPath()}product_block.template";
     }
     return(productBlockTemplateFullPath);
 }
Beispiel #2
0
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();

        services.AddScoped(provider =>
        {
            IHostingEnvironment env = services.BuildServiceProvider().GetRequiredService <IHostingEnvironment>();
            return(new ConfigurationHandler(env.GetConfigsFolderFullPath() + "config.json"));
        });

        services.AddDbContext <CMSDatabase>(options =>
        {
            ConfigurationHandler configHandler = services.BuildServiceProvider().GetRequiredService <ConfigurationHandler>();
            switch (configHandler.DbConfiguration["Database"].ToLower())
            {
            case "mssql":
                options.UseSqlServer(configHandler.DbConfiguration["ConnectionString"]);
                break;

            case "mysql":
                options.UseMySql(configHandler.DbConfiguration["ConnectionString"]);
                break;
            }
        });

        services.AddTransient(provider =>
        {
            ConfigurationHandler configHandler = services.BuildServiceProvider().GetRequiredService <ConfigurationHandler>();
            return(new AccessLevelConfiguration(configHandler.AccessConfiguration));
        });

        services.AddSingleton <EnRuTranslit>();

        services.AddTransient <ILoginFormLocalization>(provider => new RuLoginFormLocalization());
        services.AddTransient <IAdminPanelPageLocalization>(provider => new RuAdminPanelPageLocalization());
        services.AddTransient <IMainPageLocalization>(provider => new RuMainPageLocalization());
        services.AddTransient <IVisitorsLocalization>(provider => new RuVisitorsLocalization());
        services.AddTransient <IPagesLocalization>(provider => new RuPagesLocalization());
        services.AddTransient <ICategoriesAndProductsLocalization>(provider => new RuCategoriesAndProductsLocalization());
        services.AddTransient <IRedirectionsLocalization>(provider => new RuRedirectionsLocalization());
        services.AddTransient <ITemplatesLocalization>(provider => new RuTemplatesLocalization());
        services.AddTransient <IFileManagerLocalization>(provider => new RuFileManagerLocalization());
        services.AddTransient <IUsersLocalization>(provider => new RuUsersLocalization());
        services.AddTransient <IUserActionsLocalization>(provider => new RuUserActionsLocalization());
        services.AddTransient <IUserTypesLocalization>(provider => new RuUserTypesLocalization());
        services.AddTransient <ISynonymsForStringsLocalization>(provider => new RuSynonymsForStringsLocalization());
        services.AddTransient <IUserProfileLocalization>(provider => new RuUserProfileLocalization());
        services.AddTransient <ISettingsLocalization>(provider => new RuSettingsLocalization());

        services.AddTransient <IAdminPanelLogLocalization>(provider => new RuAdminPanelLogLocalization());

        services.AddHostedService <TimedHostedService>();

        services.AddMvc();

        services.Configure <ForwardedHeadersOptions>(options => options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto);
    }