Use built-in Enum parse method, avoids keeping single-use Enums in memory
This commit is contained in:
@@ -81,15 +81,16 @@ public class SqlServerSyntaxProvider : MicrosoftSqlSyntaxProviderBase<SqlServerS
|
||||
var setting = _globalSettings.Value.DatabaseFactoryServerVersion;
|
||||
var fromSettings = false;
|
||||
|
||||
if (setting.IsNullOrWhiteSpace() || !setting.StartsWith("SqlServer.")
|
||||
|| !Enum<VersionName>.TryParse(setting.Substring("SqlServer.".Length), out VersionName versionName, true))
|
||||
if (setting.IsNullOrWhiteSpace() || !setting.StartsWith("SqlServer.") || !Enum.TryParse(setting.AsSpan("SqlServer.".Length), true, out VersionName versionName))
|
||||
{
|
||||
versionName = GetSetVersion(connectionString, ProviderName, _logger).ProductVersionName;
|
||||
}
|
||||
|
||||
if (_logger.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug))
|
||||
{
|
||||
_logger.LogDebug("SqlServer {SqlServerVersion}, DatabaseType is {DatabaseType} ({Source}).", versionName, DatabaseType.SqlServer2012, fromSettings ? "settings" : "detected");
|
||||
}
|
||||
|
||||
return DatabaseType.SqlServer2012;
|
||||
}
|
||||
|
||||
|
||||
@@ -191,7 +191,7 @@ public class ContentSettings
|
||||
/// Gets or sets a value for the macro error behaviour.
|
||||
/// </summary>
|
||||
[DefaultValue(StaticMacroErrors)]
|
||||
public MacroErrorBehaviour MacroErrors { get; set; } = Enum<MacroErrorBehaviour>.Parse(StaticMacroErrors);
|
||||
public MacroErrorBehaviour MacroErrors { get; set; } = Enum.Parse<MacroErrorBehaviour>(StaticMacroErrors);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value for the collection of file extensions that are disallowed for upload.
|
||||
@@ -243,7 +243,7 @@ public class ContentSettings
|
||||
public bool DisableUnpublishWhenReferenced { get; set; } = StaticDisableUnpublishWhenReferenced;
|
||||
|
||||
/// <summary>
|
||||
/// Get or sets the model representing the global content version cleanup policy
|
||||
/// Gets or sets the model representing the global content version cleanup policy
|
||||
/// </summary>
|
||||
public ContentVersionCleanupPolicySettings ContentVersionCleanupPolicy { get; set; } = new();
|
||||
|
||||
|
||||
@@ -25,8 +25,7 @@ public class HealthChecksNotificationMethodSettings
|
||||
/// Gets or sets a value for the health check notifications reporting verbosity.
|
||||
/// </summary>
|
||||
[DefaultValue(StaticVerbosity)]
|
||||
public HealthCheckNotificationVerbosity Verbosity { get; set; } =
|
||||
Enum<HealthCheckNotificationVerbosity>.Parse(StaticVerbosity);
|
||||
public HealthCheckNotificationVerbosity Verbosity { get; set; } = Enum.Parse<HealthCheckNotificationVerbosity>(StaticVerbosity);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the health check notifications should occur on failures only.
|
||||
|
||||
@@ -23,8 +23,7 @@ public class HostingSettings
|
||||
/// Gets or sets a value for the location of temporary files.
|
||||
/// </summary>
|
||||
[DefaultValue(StaticLocalTempStorageLocation)]
|
||||
public LocalTempStorage LocalTempStorageLocation { get; set; } =
|
||||
Enum<LocalTempStorage>.Parse(StaticLocalTempStorageLocation);
|
||||
public LocalTempStorage LocalTempStorageLocation { get; set; } = Enum.Parse<LocalTempStorage>(StaticLocalTempStorageLocation);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether umbraco is running in [debug mode].
|
||||
|
||||
@@ -22,7 +22,7 @@ public class ModelsBuilderSettings
|
||||
/// Gets or sets a value for the models mode.
|
||||
/// </summary>
|
||||
[DefaultValue(StaticModelsMode)]
|
||||
public ModelsMode ModelsMode { get; set; } = Enum<ModelsMode>.Parse(StaticModelsMode);
|
||||
public ModelsMode ModelsMode { get; set; } = Enum.Parse<ModelsMode>(StaticModelsMode);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value for models namespace.
|
||||
@@ -52,10 +52,9 @@ public class ModelsBuilderSettings
|
||||
return _flagOutOfDateModels;
|
||||
}
|
||||
|
||||
set => _flagOutOfDateModels = value;
|
||||
set => _flagOutOfDateModels = value;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value for the models directory.
|
||||
/// </summary>
|
||||
|
||||
@@ -24,8 +24,7 @@ public class NuCacheSettings
|
||||
/// The serializer type that nucache uses to persist documents in the database.
|
||||
/// </summary>
|
||||
[DefaultValue(StaticNuCacheSerializerType)]
|
||||
public NuCacheSerializerType NuCacheSerializerType { get; set; } =
|
||||
Enum<NuCacheSerializerType>.Parse(StaticNuCacheSerializerType);
|
||||
public NuCacheSerializerType NuCacheSerializerType { get; set; } = Enum.Parse<NuCacheSerializerType>(StaticNuCacheSerializerType);
|
||||
|
||||
/// <summary>
|
||||
/// The paging size to use for nucache SQL queries.
|
||||
|
||||
@@ -19,8 +19,7 @@ public class RuntimeMinificationSettings
|
||||
/// The cache buster type to use
|
||||
/// </summary>
|
||||
[DefaultValue(StaticCacheBuster)]
|
||||
public RuntimeMinificationCacheBuster CacheBuster { get; set; } =
|
||||
Enum<RuntimeMinificationCacheBuster>.Parse(StaticCacheBuster);
|
||||
public RuntimeMinificationCacheBuster CacheBuster { get; set; } = Enum.Parse<RuntimeMinificationCacheBuster>(StaticCacheBuster);
|
||||
|
||||
/// <summary>
|
||||
/// The unique version string used if CacheBuster is 'Version'.
|
||||
|
||||
@@ -74,8 +74,7 @@ public class SmtpSettings : ValidatableEntryBase
|
||||
/// Gets or sets a value for the secure socket options.
|
||||
/// </summary>
|
||||
[DefaultValue(StaticSecureSocketOptions)]
|
||||
public SecureSocketOptions SecureSocketOptions { get; set; } =
|
||||
Enum<SecureSocketOptions>.Parse(StaticSecureSocketOptions);
|
||||
public SecureSocketOptions SecureSocketOptions { get; set; } = Enum.Parse<SecureSocketOptions>(StaticSecureSocketOptions);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value for the SMTP pick-up directory.
|
||||
@@ -86,7 +85,7 @@ public class SmtpSettings : ValidatableEntryBase
|
||||
/// Gets or sets a value for the SMTP delivery method.
|
||||
/// </summary>
|
||||
[DefaultValue(StaticDeliveryMethod)]
|
||||
public SmtpDeliveryMethod DeliveryMethod { get; set; } = Enum<SmtpDeliveryMethod>.Parse(StaticDeliveryMethod);
|
||||
public SmtpDeliveryMethod DeliveryMethod { get; set; } = Enum.Parse<SmtpDeliveryMethod>(StaticDeliveryMethod);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value for the SMTP user name.
|
||||
|
||||
@@ -75,7 +75,7 @@ public class WebRoutingSettings
|
||||
/// Gets or sets a value for the URL provider mode (<see cref="UrlMode" />).
|
||||
/// </summary>
|
||||
[DefaultValue(StaticUrlProviderMode)]
|
||||
public UrlMode UrlProviderMode { get; set; } = Enum<UrlMode>.Parse(StaticUrlProviderMode);
|
||||
public UrlMode UrlProviderMode { get; set; } = Enum.Parse<UrlMode>(StaticUrlProviderMode);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value for the Umbraco application URL.
|
||||
|
||||
Reference in New Issue
Block a user