mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 03:25:23 +08:00
Moved shell settings initialization from MissingSettingsBanner into the providers themselves.
This commit is contained in:

committed by
Sebastien Ros

parent
ca34a462b6
commit
2814794bd2
@@ -4,6 +4,7 @@ using Orchard.Data;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Logging;
|
||||
using System.Linq;
|
||||
|
||||
namespace Orchard.Azure.Services.Caching.Database {
|
||||
|
||||
@@ -14,12 +15,23 @@ namespace Orchard.Azure.Services.Caching.Database {
|
||||
public static string CacheHostIdentifier;
|
||||
public static string CacheName;
|
||||
|
||||
public AzureCacheConfiguration(ShellSettings shellSettings)
|
||||
public AzureCacheConfiguration(IShellSettingsManager shellSettingsManager, ShellSettings shellSettings)
|
||||
: base() {
|
||||
_shellSettings = shellSettings;
|
||||
|
||||
// Create default configuration to local role-based cache when feature is enabled.
|
||||
if (!shellSettings.Keys.Contains(Constants.DatabaseCacheHostIdentifierSettingName))
|
||||
shellSettings[Constants.DatabaseCacheHostIdentifierSettingName] = "Orchard.Azure.Web";
|
||||
if (!shellSettings.Keys.Contains(Constants.DatabaseCacheCacheNameSettingName))
|
||||
shellSettings[Constants.DatabaseCacheCacheNameSettingName] = "DatabaseCache";
|
||||
if (!shellSettings.Keys.Contains(Constants.DatabaseCacheIsSharedCachingSettingName))
|
||||
shellSettings[Constants.DatabaseCacheIsSharedCachingSettingName] = "false";
|
||||
|
||||
shellSettingsManager.SaveSettings(shellSettings);
|
||||
|
||||
CacheHostIdentifier = shellSettings[Constants.DatabaseCacheHostIdentifierSettingName];
|
||||
CacheName = shellSettings[Constants.DatabaseCacheCacheNameSettingName];
|
||||
|
||||
_shellSettings = shellSettings;
|
||||
}
|
||||
|
||||
private readonly ShellSettings _shellSettings;
|
||||
@@ -28,7 +40,6 @@ namespace Orchard.Azure.Services.Caching.Database {
|
||||
cache.Provider<AzureCacheProvider>();
|
||||
cache.UseQueryCache = true;
|
||||
cache.RegionsPrefix = _shellSettings.Name;
|
||||
//cache.RegionsPrefix = "Orchard";
|
||||
|
||||
Logger.Information("Configured NHibernate cache provider '{0}' with regions prefix '{1}'.", typeof(AzureCacheProvider).Name, _shellSettings.Name);
|
||||
}
|
||||
|
@@ -14,9 +14,19 @@ namespace Orchard.Azure.Services.Caching.Output {
|
||||
[OrchardSuppressDependency("Orchard.OutputCache.Services.DefaultCacheStorageProvider")]
|
||||
public class AzureOutputCacheStorageProvider : Component, IOutputCacheStorageProvider {
|
||||
|
||||
public AzureOutputCacheStorageProvider(ShellSettings shellSettings)
|
||||
public AzureOutputCacheStorageProvider(IShellSettingsManager shellSettingsManager, ShellSettings shellSettings)
|
||||
: base() {
|
||||
|
||||
// Create default configuration to local role-based cache when feature is enabled.
|
||||
if (!shellSettings.Keys.Contains(Constants.OutputCacheHostIdentifierSettingName))
|
||||
shellSettings[Constants.OutputCacheHostIdentifierSettingName] = "Orchard.Azure.Web";
|
||||
if (!shellSettings.Keys.Contains(Constants.OutputCacheCacheNameSettingName))
|
||||
shellSettings[Constants.OutputCacheCacheNameSettingName] = "OutputCache";
|
||||
if (!shellSettings.Keys.Contains(Constants.OutputCacheIsSharedCachingSettingName))
|
||||
shellSettings[Constants.OutputCacheIsSharedCachingSettingName] = "false";
|
||||
|
||||
shellSettingsManager.SaveSettings(shellSettings);
|
||||
|
||||
var cacheHostIdentifier = shellSettings[Constants.OutputCacheHostIdentifierSettingName];
|
||||
var cacheName = shellSettings[Constants.OutputCacheCacheNameSettingName];
|
||||
|
||||
|
@@ -44,14 +44,6 @@ namespace Orchard.Azure.Services {
|
||||
}
|
||||
|
||||
if (enabledFeatureNamesQuery.Contains(Constants.OutputCacheFeatureName)) {
|
||||
// Create default configuration to local role-based cache when feature is enabled.
|
||||
if (!_shellSettings.Keys.Contains(Constants.OutputCacheHostIdentifierSettingName))
|
||||
_shellSettings[Constants.OutputCacheHostIdentifierSettingName] = "Orchard.Azure.Web";
|
||||
if (!_shellSettings.Keys.Contains(Constants.OutputCacheCacheNameSettingName))
|
||||
_shellSettings[Constants.OutputCacheCacheNameSettingName] = "OutputCache";
|
||||
if (!_shellSettings.Keys.Contains(Constants.OutputCacheIsSharedCachingSettingName))
|
||||
_shellSettings[Constants.OutputCacheIsSharedCachingSettingName] = "false";
|
||||
|
||||
if (String.IsNullOrWhiteSpace(_shellSettings[Constants.OutputCacheHostIdentifierSettingName]))
|
||||
yield return new NotifyEntry {
|
||||
Message = T("A cache cluster host identifier must be configured in the shell setting '{0}'.", Constants.OutputCacheHostIdentifierSettingName),
|
||||
@@ -71,14 +63,6 @@ namespace Orchard.Azure.Services {
|
||||
}
|
||||
|
||||
if (enabledFeatureNamesQuery.Contains(Constants.DatabaseCacheFeatureName)) {
|
||||
// Create default configuration to local role-based cache when feature is enabled.
|
||||
if (!_shellSettings.Keys.Contains(Constants.DatabaseCacheHostIdentifierSettingName))
|
||||
_shellSettings[Constants.DatabaseCacheHostIdentifierSettingName] = "Orchard.Azure.Web";
|
||||
if (!_shellSettings.Keys.Contains(Constants.DatabaseCacheCacheNameSettingName))
|
||||
_shellSettings[Constants.DatabaseCacheCacheNameSettingName] = "DatabaseCache";
|
||||
if (!_shellSettings.Keys.Contains(Constants.DatabaseCacheIsSharedCachingSettingName))
|
||||
_shellSettings[Constants.DatabaseCacheIsSharedCachingSettingName] = "false";
|
||||
|
||||
if (String.IsNullOrWhiteSpace(_shellSettings[Constants.DatabaseCacheHostIdentifierSettingName]))
|
||||
yield return new NotifyEntry {
|
||||
Message = T("A cache cluster host identifier must be configured in the shell setting '{0}'.", Constants.DatabaseCacheHostIdentifierSettingName),
|
||||
|
Reference in New Issue
Block a user