Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Minor improvements - move application settings to the new class ExtensionsConfig (changes in App_Settings)
support6007eb928811
diff --git a/src/Core/Grand.Infrastructure/Configuration/AppConfig.cs b/src/Core/Grand.Infrastructure/Configuration/AppConfig.csindex 399d7c736..f72336dba 100644--- a/src/Core/Grand.Infrastructure/Configuration/AppConfig.cs+++ b/src/Core/Grand.Infrastructure/Configuration/AppConfig.cs@@ -10,11 +10,6 @@ namespace Grand.Infrastructure.ConfigurationSupportedCultures = new List<string>();}- /// <summary>- /// Indicates whether we disabled upload plugins/themes- /// </summary>- public bool DisableUploadExtensions { get; set; }-/// <summary>/// Indicates whether we should Disable HostedService - BackgroundServiceTask/// </summary>@@ -25,27 +20,6 @@ namespace Grand.Infrastructure.Configuration/// </summary>public bool SkipMigrationProcess { get; set; }- /// <summary>- /// Gets or sets a value indicating whether to clear /Plugins/bin directory on application startup- /// </summary>- public bool ClearPluginShadowDirectoryOnStartup { get; set; }-- /// <summary>- /// Gets or sets a value indicating whether copy dll plugin files to /Plugins/bin on application startup- /// </summary>- public bool PluginShadowCopy { get; set; }--- /// <summary>- /// A list of plugins to be ignored during start application - pattern- /// </summary>- public string PluginSkipLoadingPattern { get; set; }-- /// <summary>- /// Enable scripting C# applications to execute code.- /// </summary>- public bool UseRoslynScripts { get; set; }-/// <summary>/// A value indicating whether SEO friendly URLs with multiple languages are enabled/// </summary>@@ -56,7 +30,6 @@ namespace Grand.Infrastructure.Configuration/// Gets or sets a value of "Cache-Control" header value for static content/// </summary>public string StaticFilesCacheControl { get; set; }-/// <summary>/// Gets or sets a value indicating whether to display the full error in production environment.diff --git a/src/Core/Grand.Infrastructure/Configuration/ExtensionsConfig.cs b/src/Core/Grand.Infrastructure/Configuration/ExtensionsConfig.csnew file mode 100644index 000000000..a1ad6bc7f--- /dev/null+++ b/src/Core/Grand.Infrastructure/Configuration/ExtensionsConfig.cs@@ -0,0 +1,29 @@+namespace Grand.Infrastructure.Configuration+{+ /// <summary>+ /// Represents a Extensions Config+ /// </summary>+ public partial class ExtensionsConfig+ {+ /// <summary>+ /// Indicates whether we disabled upload plugins/themes+ /// </summary>+ public bool DisableUploadExtensions { get; set; }++ /// <summary>+ /// Gets or sets a value indicating whether copy dll plugin files to /Plugins/bin on application startup+ /// </summary>+ public bool PluginShadowCopy { get; set; }++ /// <summary>+ /// A list of plugins to be ignored during start application - pattern+ /// </summary>+ public string PluginSkipLoadingPattern { get; set; }++ /// <summary>+ /// Enable scripting C# applications to execute code.+ /// </summary>+ public bool UseRoslynScripts { get; set; }++ }+}diff --git a/src/Core/Grand.Infrastructure/Plugins/PluginManager.cs b/src/Core/Grand.Infrastructure/Plugins/PluginManager.csindex c56a1eadc..01d30b384 100644--- a/src/Core/Grand.Infrastructure/Plugins/PluginManager.cs+++ b/src/Core/Grand.Infrastructure/Plugins/PluginManager.cs@@ -27,7 +27,7 @@ namespace Grand.Infrastructure.Pluginsprivate static DirectoryInfo _copyFolder;private static DirectoryInfo _pluginFolder;- private static AppConfig _config;+ private static ExtensionsConfig _config;#endregion@@ -43,7 +43,7 @@ namespace Grand.Infrastructure.Plugins/// Load plugins/// </summary>[MethodImpl(MethodImplOptions.NoInlining)]- public static void Load(IMvcCoreBuilder mvcCoreBuilder, AppConfig config)+ public static void Load(IMvcCoreBuilder mvcCoreBuilder, ExtensionsConfig config){lock (_synLock){@@ -64,7 +64,7 @@ namespace Grand.Infrastructure.PluginsDirectory.CreateDirectory(_pluginFolder.FullName);Directory.CreateDirectory(_copyFolder.FullName);var binFiles = _copyFolder.GetFiles("*", SearchOption.AllDirectories);- if (config.ClearPluginShadowDirectoryOnStartup)+ if (config.PluginShadowCopy){//clear out shadow pluginsforeach (var f in binFiles)diff --git a/src/Core/Grand.Infrastructure/Roslyn/RoslynCompiler.cs b/src/Core/Grand.Infrastructure/Roslyn/RoslynCompiler.csindex 8a233a6cb..564ceeb26 100644--- a/src/Core/Grand.Infrastructure/Roslyn/RoslynCompiler.cs+++ b/src/Core/Grand.Infrastructure/Roslyn/RoslynCompiler.cs@@ -26,7 +26,7 @@ namespace Grand.Infrastructure.Roslyn#endregion- public static void Load(ApplicationPartManager applicationPartManager, AppConfig config)+ public static void Load(ApplicationPartManager applicationPartManager, ExtensionsConfig config){if (applicationPartManager == null)throw new ArgumentNullException(nameof(applicationPartManager));diff --git a/src/Core/Grand.Infrastructure/StartupBase.cs b/src/Core/Grand.Infrastructure/StartupBase.csindex 5e291476e..c57a021fa 100644--- a/src/Core/Grand.Infrastructure/StartupBase.cs+++ b/src/Core/Grand.Infrastructure/StartupBase.cs@@ -123,8 +123,8 @@ namespace Grand.Infrastructure/// <param name="configuration"></param>private static void RegisterExtensions(IMvcCoreBuilder mvcCoreBuilder, IConfiguration configuration){- var config = new AppConfig();- configuration.GetSection("Application").Bind(config);+ var config = new ExtensionsConfig();+ configuration.GetSection("Extensions").Bind(config);//Load pluginsPluginManager.Load(mvcCoreBuilder, config);@@ -190,9 +190,10 @@ namespace Grand.Infrastructureservices.AddWkhtmltopdf();//add AppConfig configuration parameters- var applicationConfig = services.StartupConfig<AppConfig>(configuration.GetSection("Application"));+ services.StartupConfig<AppConfig>(configuration.GetSection("Application"));var performanceConfig = services.StartupConfig<PerformanceConfig>(configuration.GetSection("Performance"));var securityConfig = services.StartupConfig<SecurityConfig>(configuration.GetSection("Security"));+ services.StartupConfig<ExtensionsConfig>(configuration.GetSection("Extensions"));services.StartupConfig<HostingConfig>(configuration.GetSection("Hosting"));services.StartupConfig<UrlRewriteConfig>(configuration.GetSection("UrlRewrite"));services.StartupConfig<RedisConfig>(configuration.GetSection("Redis"));diff --git a/src/Web/Grand.Web.Admin/Controllers/PluginController.cs b/src/Web/Grand.Web.Admin/Controllers/PluginController.csindex e64fff333..dbb77f6c7 100644--- a/src/Web/Grand.Web.Admin/Controllers/PluginController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/PluginController.cs@@ -31,7 +31,7 @@ namespace Grand.Web.Admin.Controllersprivate readonly IHostApplicationLifetime _applicationLifetime;private readonly IServiceProvider _serviceProvider;private readonly IWorkContext _workContext;- private readonly AppConfig _appConfig;+ private readonly ExtensionsConfig _extConfig;#endregion#region Constructors@@ -43,7 +43,7 @@ namespace Grand.Web.Admin.ControllersIHostApplicationLifetime applicationLifetime,IWorkContext workContext,IServiceProvider serviceProvider,- AppConfig appConfig)+ ExtensionsConfig extConfig){_translationService = translationService;_themeProvider = themeProvider;@@ -51,7 +51,7 @@ namespace Grand.Web.Admin.Controllers_workContext = workContext;_applicationLifetime = applicationLifetime;_serviceProvider = serviceProvider;- _appConfig = appConfig;+ _extConfig = extConfig;}#endregion@@ -242,7 +242,7 @@ namespace Grand.Web.Admin.Controllers[HttpPost]public IActionResult Remove(IFormCollection form){- if (_appConfig.DisableUploadExtensions)+ if (_extConfig.DisableUploadExtensions){Error("Upload plugins/themes is disable");return RedirectToAction("List");@@ -300,7 +300,7 @@ namespace Grand.Web.Admin.Controllers[HttpPost]public IActionResult UploadPlugin(IFormFile zippedFile){- if(_appConfig.DisableUploadExtensions)+ if(_extConfig.DisableUploadExtensions){Error("Upload plugins/themes is disable");return RedirectToAction("List");@@ -349,7 +349,7 @@ namespace Grand.Web.Admin.Controllers[HttpPost]public IActionResult UploadTheme(IFormFile zippedFile){- if (_appConfig.DisableUploadExtensions)+ if (_extConfig.DisableUploadExtensions){Error("Upload plugins/themes is disable");return RedirectToAction("GeneralCommon", "Setting");diff --git a/src/Web/Grand.Web.Admin/Controllers/SystemController.cs b/src/Web/Grand.Web.Admin/Controllers/SystemController.csindex 79e1ac5e9..d37119e32 100644--- a/src/Web/Grand.Web.Admin/Controllers/SystemController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/SystemController.cs@@ -41,7 +41,7 @@ namespace Grand.Web.Admin.Controllersprivate readonly CurrencySettings _currencySettings;private readonly MeasureSettings _measureSettings;- private readonly AppConfig _appConfig;+ private readonly ExtensionsConfig _extConfig;#endregion#region Constructors@@ -58,7 +58,7 @@ namespace Grand.Web.Admin.ControllersILogger logger,CurrencySettings currencySettings,MeasureSettings measureSettings,- AppConfig appConfig)+ ExtensionsConfig extConfig){_paymentService = paymentService;_shippingService = shippingService;@@ -71,7 +71,7 @@ namespace Grand.Web.Admin.Controllers_translationService = translationService;_applicationLifetime = applicationLifetime;_logger = logger;- _appConfig = appConfig;+ _extConfig = extConfig;_machineNameProvider = machineNameProvider;}@@ -300,7 +300,7 @@ namespace Grand.Web.Admin.Controllerspublic IActionResult Roslyn(){- return View(_appConfig.UseRoslynScripts);+ return View(_extConfig.UseRoslynScripts);}[HttpPost]diff --git a/src/Web/Grand.Web/App_Data/appsettings.json b/src/Web/Grand.Web/App_Data/appsettings.jsonindex 6cbd892ad..91a97f14c 100644--- a/src/Web/Grand.Web/App_Data/appsettings.json+++ b/src/Web/Grand.Web/App_Data/appsettings.json@@ -16,11 +16,6 @@"DisplayFullErrorStack": true,//Value of "Cache-Control" header value for static content"StaticFilesCacheControl": "public,max-age=31536000",-- //Disable upload extensions plugins/themes- "DisableUploadExtensions": false,- //A list of plugins to be ignored during start application - pattern- "PluginSkipLoadingPattern": "",//Ignore the migration process"SkipMigrationProcess": false,@@ -28,10 +23,6 @@//Enable the session-based TempData provider"UseSessionStateTempDataProvider": false,- //For developers - more info you can find at https://docs.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/- //https://github.com/dotnet/roslyn/wiki/Roslyn-Overview- "UseRoslynScripts": false,-//A value indicating whether SEO friendly URLs with multiple languages are enabled"SeoFriendlyUrlsForLanguagesEnabled": false,"SeoFriendlyUrlsDefaultCode": "en",@@ -44,15 +35,10 @@"SupportedCultures": [ "en-US", "pl-PL" ],//Indicates whether to disable hosted service - BackgroundServiceTask"DisableHostedService": false,-- //Enable if you want to clear /Plugins/bin directory on application startup- "ClearPluginShadowDirectoryOnStartup": true,- //For develop you should enable if you want to copy plugin dll files to directory /Plugins/bin on application startup- "PluginShadowCopy": true,-//(Serilog) Request logging - The package includes middleware for smarter HTTP request logging."UseSerilogRequestLogging": false},+"Security": {//This settings adds the following headers to all responses that pass//X-Content-Type-Options: nosniff@@ -85,7 +71,21 @@//This is the one you should be targeting if your production environment fully runs on HTTPS"CookieSecurePolicyAlways": false},+ "Extensions": {++ //For developers - more info you can find at https://docs.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/+ //https://github.com/dotnet/roslyn/wiki/Roslyn-Overview+ "UseRoslynScripts": false,+ //Disable upload extensions plugins/themes+ "DisableUploadExtensions": false,+ //A list of plugins to be ignored during start application - pattern+ "PluginSkipLoadingPattern": "",+ //Enable if you want to clear /Plugins/bin directory on application startup+ "ClearPluginShadowDirectoryOnStartup": true,+ //For develop you should enable if you want to copy plugin dll files to directory /Plugins/bin on application startup+ "PluginShadowCopy": true+ },"Performance": {//Flag for whether to enable html minification"UseHtmlMinification": false,