Finish up remaining AppSetting keys as Constants

This commit is contained in:
Warren Buckley
2019-01-31 12:05:56 +00:00
parent 34be548aec
commit 69f7a1b7b9
14 changed files with 81 additions and 43 deletions

View File

@@ -32,7 +32,7 @@ namespace Umbraco.Core.Composing
if (_assembliesAcceptingLoadExceptions != null)
return _assembliesAcceptingLoadExceptions;
var s = ConfigurationManager.AppSettings["Umbraco.AssembliesAcceptingLoadExceptions"];
var s = ConfigurationManager.AppSettings[Constants.AppSettings.AssembliesAcceptingLoadExceptions];
return _assembliesAcceptingLoadExceptions = string.IsNullOrWhiteSpace(s)
? Array.Empty<string>()
: s.Split(',').Select(x => x.Trim()).ToArray();

View File

@@ -7,8 +7,8 @@ namespace Umbraco.Core.Configuration
public CoreDebug()
{
var appSettings = System.Configuration.ConfigurationManager.AppSettings;
LogUncompletedScopes = string.Equals("true", appSettings["Umbraco.CoreDebug.LogUncompletedScopes"], StringComparison.OrdinalIgnoreCase);
DumpOnTimeoutThreadAbort = string.Equals("true", appSettings["Umbraco.CoreDebug.DumpOnTimeoutThreadAbort"], StringComparison.OrdinalIgnoreCase);
LogUncompletedScopes = string.Equals("true", appSettings[Constants.AppSettings.Debug.LogUncompletedScopes], StringComparison.OrdinalIgnoreCase);
DumpOnTimeoutThreadAbort = string.Equals("true", appSettings[Constants.AppSettings.Debug.DumpOnTimeoutThreadAbort], StringComparison.OrdinalIgnoreCase);
}
// when true, Scope logs the stack trace for any scope that gets disposed without being completed.

View File

@@ -85,8 +85,8 @@ namespace Umbraco.Core.Configuration
{
if (_reservedUrls != null) return _reservedUrls;
var urls = ConfigurationManager.AppSettings.ContainsKey("umbracoReservedUrls")
? ConfigurationManager.AppSettings["umbracoReservedUrls"]
var urls = ConfigurationManager.AppSettings.ContainsKey(Constants.AppSettings.ReservedUrls)
? ConfigurationManager.AppSettings[Constants.AppSettings.ReservedUrls]
: string.Empty;
//ensure the built on (non-changeable) reserved paths are there at all times
@@ -107,14 +107,14 @@ namespace Umbraco.Core.Configuration
if (_reservedPaths != null) return _reservedPaths;
var reservedPaths = StaticReservedPaths;
var umbPath = ConfigurationManager.AppSettings.ContainsKey("umbracoPath") && !ConfigurationManager.AppSettings["umbracoPath"].IsNullOrWhiteSpace()
? ConfigurationManager.AppSettings["umbracoPath"]
var umbPath = ConfigurationManager.AppSettings.ContainsKey(Constants.AppSettings.Path) && !ConfigurationManager.AppSettings[Constants.AppSettings.Path].IsNullOrWhiteSpace()
? ConfigurationManager.AppSettings[Constants.AppSettings.Path]
: "~/umbraco";
//always add the umbraco path to the list
reservedPaths += umbPath.EnsureEndsWith(',');
var allPaths = ConfigurationManager.AppSettings.ContainsKey("umbracoReservedPaths")
? ConfigurationManager.AppSettings["umbracoReservedPaths"]
var allPaths = ConfigurationManager.AppSettings.ContainsKey(Constants.AppSettings.ReservedPaths)
? ConfigurationManager.AppSettings[Constants.AppSettings.ReservedPaths]
: string.Empty;
_reservedPaths = reservedPaths + allPaths;
@@ -133,8 +133,8 @@ namespace Umbraco.Core.Configuration
{
get
{
return ConfigurationManager.AppSettings.ContainsKey("umbracoContentXML")
? ConfigurationManager.AppSettings["umbracoContentXML"]
return ConfigurationManager.AppSettings.ContainsKey(Constants.AppSettings.ContentXML)
? ConfigurationManager.AppSettings[Constants.AppSettings.ContentXML]
: "~/App_Data/umbraco.config";
}
}
@@ -147,8 +147,8 @@ namespace Umbraco.Core.Configuration
{
get
{
return ConfigurationManager.AppSettings.ContainsKey("umbracoPath")
? IOHelper.ResolveUrl(ConfigurationManager.AppSettings["umbracoPath"])
return ConfigurationManager.AppSettings.ContainsKey(Constants.AppSettings.Path)
? IOHelper.ResolveUrl(ConfigurationManager.AppSettings[Constants.AppSettings.Path])
: string.Empty;
}
}
@@ -249,7 +249,7 @@ namespace Umbraco.Core.Configuration
{
try
{
return int.Parse(ConfigurationManager.AppSettings["umbracoTimeOutInMinutes"]);
return int.Parse(ConfigurationManager.AppSettings[Constants.AppSettings.TimeOutInMinutes]);
}
catch
{
@@ -268,7 +268,7 @@ namespace Umbraco.Core.Configuration
{
try
{
return int.Parse(ConfigurationManager.AppSettings["umbracoVersionCheckPeriod"]);
return int.Parse(ConfigurationManager.AppSettings[Constants.AppSettings.VersionCheckPeriod]);
}
catch
{
@@ -287,7 +287,7 @@ namespace Umbraco.Core.Configuration
{
get
{
var setting = ConfigurationManager.AppSettings["umbracoLocalTempStorage"];
var setting = ConfigurationManager.AppSettings[Constants.AppSettings.LocalTempStorage];
if (!string.IsNullOrWhiteSpace(setting))
return Enum<LocalTempStorage>.Parse(setting);
@@ -304,8 +304,8 @@ namespace Umbraco.Core.Configuration
{
get
{
return ConfigurationManager.AppSettings.ContainsKey("umbracoDefaultUILanguage")
? ConfigurationManager.AppSettings["umbracoDefaultUILanguage"]
return ConfigurationManager.AppSettings.ContainsKey(Constants.AppSettings.DefaultUILanguage)
? ConfigurationManager.AppSettings[Constants.AppSettings.DefaultUILanguage]
: string.Empty;
}
}
@@ -322,7 +322,7 @@ namespace Umbraco.Core.Configuration
{
try
{
return bool.Parse(ConfigurationManager.AppSettings["umbracoHideTopLevelNodeFromPath"]);
return bool.Parse(ConfigurationManager.AppSettings[Constants.AppSettings.HideTopLevelNodeFromPath]);
}
catch
{
@@ -340,7 +340,7 @@ namespace Umbraco.Core.Configuration
{
try
{
return bool.Parse(ConfigurationManager.AppSettings["umbracoUseHttps"]);
return bool.Parse(ConfigurationManager.AppSettings[Constants.AppSettings.UseHttps]);
}
catch
{

View File

@@ -82,7 +82,7 @@ namespace Umbraco.Core.Configuration
try
{
// TODO: https://github.com/umbraco/Umbraco-CMS/issues/4238 - stop having version in web.config appSettings
var value = ConfigurationManager.AppSettings["umbracoConfigurationStatus"];
var value = ConfigurationManager.AppSettings[Constants.AppSettings.ConfigurationStatus];
return value.IsNullOrWhiteSpace() ? null : SemVersion.TryParse(value, out var semver) ? semver : null;
}
catch

View File

@@ -10,11 +10,48 @@ namespace Umbraco.Core
/// </summary>
public static class AppSettings
{
// TODO: Kill me - still used in Umbraco.Core.IO.SystemFiles:27
[Obsolete("We need to kill this appsetting as we do not use XML content cache umbraco.config anymore due to NuCache")]
public const string ContentXML = "Umbraco.Core.ContentXML"; //umbracoContentXML
public const string RegisterType = "Umbraco.Core.RegisterType";
public const string PublishedMediaCacheSeconds = "Umbraco.Core.PublishedMediaCacheSeconds"; //"Umbraco.PublishedMediaCache.Seconds"
public const string AssembliesAcceptingLoadExceptions = "Umbraco.Core.AssembliesAcceptingLoadExceptions"; //Umbraco.AssembliesAcceptingLoadExceptions
public const string ConfigurationStatus = "Umbraco.Core.ConfigurationStatus"; //umbracoConfigurationStatus
public const string Path = "Umbraco.Core.Path"; //umbracoPath
public const string ReservedUrls = "Umbraco.Core.ReservedUrls"; //umbracoReservedUrls
public const string ReservedPaths = "Umbraco.Core.ReservedPaths"; //umbracoReservedPaths
public const string TimeOutInMinutes = "Umbraco.Core.TimeOutInMinutes"; //umbracoTimeOutInMinutes
public const string VersionCheckPeriod = "Umbraco.Core.VersionCheckPeriod"; //umbracoVersionCheckPeriod
public const string LocalTempStorage = "Umbraco.Core.LocalTempStorage"; //umbracoLocalTempStorage
public const string DefaultUILanguage = "Umbraco.Core.DefaultUILanguage"; //umbracoDefaultUILanguage
public const string HideTopLevelNodeFromPath = "Umbraco.Core.HideTopLevelNodeFromPath"; //umbracoHideTopLevelNodeFromPath
public const string UseHttps = "Umbraco.Core.UseHttps"; //umbracoUseHttps
public const string DisableElectionForSingleServer = "Umbraco.Core.DisableElectionForSingleServer"; //umbracoDisableElectionForSingleServer
public const string DatabaseFactoryServerVersion = "Umbraco.Core.DatabaseFactoryServerVersion"; //Umbraco.DatabaseFactory.ServerVersion
public static class Debug
{
public const string LogUncompletedScopes = "Umbraco.Core.LogUncompletedScopes"; //"Umbraco.CoreDebug.LogUncompletedScopes"
public const string DumpOnTimeoutThreadAbort = "Umbraco.Core.DumpOnTimeoutThreadAbort"; //Umbraco.CoreDebug.DumpOnTimeoutThreadAbort
}
}
}
}

View File

@@ -8,7 +8,8 @@ namespace Umbraco.Core.IO
public class SystemFiles
{
public static string TinyMceConfig => SystemDirectories.Config + "/tinyMceConfig.config";
// TODO: Kill this off we don't have umbraco.config XML cache we now have NuCache
public static string GetContentCacheXml(IGlobalSettings globalSettings)
{
switch (globalSettings.LocalTempStorageLocation)
@@ -24,7 +25,7 @@ namespace Umbraco.Core.IO
appDomainHash);
return Path.Combine(cachePath, "umbraco.config");
case LocalTempStorage.Default:
return IOHelper.ReturnPath("umbracoContentXML", "~/App_Data/umbraco.config");
return IOHelper.ReturnPath(Constants.AppSettings.ContentXML, "~/App_Data/umbraco.config");
default:
throw new ArgumentOutOfRangeException();
}

View File

@@ -67,7 +67,7 @@ namespace Umbraco.Core.Models
// culture
//
// I assume that, on a site, all language names should be in the SAME language, in DB,
// and that would be the umbracoDefaultUILanguage (app setting) - BUT if by accident
// and that would be the Umbraco.Core.DefaultUILanguage (app setting) - BUT if by accident
// ANY culture has been retrieved with another current thread culture - it's now corrupt
//
// so, the logic below ensures that the name always end up being the correct name

View File

@@ -139,7 +139,7 @@ namespace Umbraco.Core.Persistence
{
// replace NPoco database type by a more efficient one
var setting = ConfigurationManager.AppSettings["Umbraco.DatabaseFactory.ServerVersion"];
var setting = ConfigurationManager.AppSettings[Constants.AppSettings.DatabaseFactoryServerVersion];
var fromSettings = false;
if (setting.IsNullOrWhiteSpace() || !setting.StartsWith("SqlServer.")

View File

@@ -76,7 +76,7 @@ namespace Umbraco.Core.Runtime
// TODO: this is a hack, use proper configuration!
// also: we still register the full IServerMessenger because
// even on 1 single server we can have 2 concurrent app domains
var singleServer = "true".InvariantEquals(ConfigurationManager.AppSettings["umbracoDisableElectionForSingleServer"]);
var singleServer = "true".InvariantEquals(ConfigurationManager.AppSettings[Constants.AppSettings.DisableElectionForSingleServer]);
return singleServer
? (IServerRegistrar) new SingleServerRegistrar(f.GetInstance<IRuntimeState>())
: new DatabaseServerRegistrar(

View File

@@ -5,14 +5,13 @@
<appSettings>
<add key="Umbraco.Core.ConfigurationStatus" value="6.0.0"/>
<add key="umbracoReservedUrls" value="~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd,~/.well-known" />
<add key="umbracoReservedPaths" value="~/install/"/>
<add key="umbracoPath" value="~/umbraco"/>
<add key="umbracoHideTopLevelNodeFromPath" value="true"/>
<add key="umbracoUseDirectoryUrls" value="false"/>
<add key="umbracoTimeOutInMinutes" value="20"/>
<add key="umbracoDefaultUILanguage" value="en"/>
<add key="umbracoUseHttps" value="false"/>
<add key="Umbraco.Core.ReservedUrls" value="~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd,~/.well-known" />
<add key="Umbraco.Core.ReservedPaths" value="~/install/"/>
<add key="Umbraco.Core.Path" value="~/umbraco"/>
<add key="Umbraco.Core.HideTopLevelNodeFromPath" value="true"/>
<add key="Umbraco.Core.TimeOutInMinutes" value="20"/>
<add key="Umbraco.Core.DefaultUILanguage" value="en"/>
<add key="Umbraco.Core.UseHttps" value="false"/>
<add key="dataAnnotations:dataTypeAttribute:disableRegEx" value="false"/>
</appSettings>

View File

@@ -645,7 +645,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
private static void InitializeCacheConfig()
{
var value = ConfigurationManager.AppSettings["Umbraco.PublishedMediaCache.Seconds"];
var value = ConfigurationManager.AppSettings[Constants.AppSettings.PublishedMediaCacheSeconds];
int seconds;
if (int.TryParse(value, out seconds) == false)
seconds = PublishedMediaCacheTimespanSeconds;

View File

@@ -31,13 +31,13 @@
<appSettings>
<add key="Umbraco.Core.ConfigurationStatus" value="" />
<add key="umbracoReservedUrls" value="" />
<add key="umbracoReservedPaths" value="" />
<add key="umbracoPath" value="~/umbraco" />
<add key="umbracoHideTopLevelNodeFromPath" value="true" />
<add key="umbracoTimeOutInMinutes" value="20" />
<add key="umbracoDefaultUILanguage" value="en-US" />
<add key="umbracoUseHttps" value="false" />
<add key="Umbraco.Core.ReservedUrls" value="" />
<add key="Umbraco.Core.ReservedPaths" value="" />
<add key="Umbraco.Core.Path" value="~/umbraco" />
<add key="Umbraco.Core.HideTopLevelNodeFromPath" value="true" />
<add key="Umbraco.Core.TimeOutInMinutes" value="20" />
<add key="Umbraco.Core.DefaultUILanguage" value="en-US" />
<add key="Umbraco.Core.UseHttps" value="false" />
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
<add key="webpages:Enabled" value="false" />

View File

@@ -248,7 +248,7 @@ namespace Umbraco.Web.Runtime
XmlFileMapper.FileMapDefaultFolder = SystemDirectories.TempData.EnsureEndsWith('/') + "ClientDependency";
BaseCompositeFileProcessingProvider.UrlTypeDefault = CompositeUrlType.Base64QueryStrings;
// Now we need to detect if we are running umbracoLocalTempStorage as EnvironmentTemp and in that case we want to change the CDF file
// Now we need to detect if we are running 'Umbraco.Core.LocalTempStorage' as EnvironmentTemp and in that case we want to change the CDF file
// location to be there
if (globalSettings.LocalTempStorageLocation == LocalTempStorage.EnvironmentTemp)
{

View File

@@ -13,6 +13,7 @@ namespace Umbraco.Web.Security
{
get
{
// TODO: Verify this AppSetting key is used in .NET Framework & canot be changed to Umbraco.Core. prefix
return ConfigurationManager.AppSettings["ActiveDirectoryDomain"];
}
}