diff --git a/src/Umbraco.Core/Configuration/ContentSettingsExtensions.cs b/src/Umbraco.Core/Configuration/ContentSettingsExtensions.cs
index 21ebe55f2f..31f4373fd2 100644
--- a/src/Umbraco.Core/Configuration/ContentSettingsExtensions.cs
+++ b/src/Umbraco.Core/Configuration/ContentSettingsExtensions.cs
@@ -1,5 +1,4 @@
-using System;
-using System.Linq;
+using System.Linq;
using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Configuration.UmbracoSettings;
@@ -7,20 +6,6 @@ namespace Umbraco.Core.Configuration
{
public static class ContentSettingsExtensions
{
- ///
- /// Gets a value indicating whether the file extension corresponds to an image.
- ///
- /// The file extension.
- ///
- /// A value indicating whether the file extension corresponds to an image.
- public static bool IsImageFile(this ContentSettings contentConfig, string extension)
- {
- if (contentConfig == null) throw new ArgumentNullException(nameof(contentConfig));
- if (extension == null) return false;
- extension = extension.TrimStart('.');
- return contentConfig.Imaging.ImageFileTypes.InvariantContains(extension);
- }
-
///
/// Determines if file extension is allowed for upload based on (optional) white list and black list
/// held in settings.
@@ -39,7 +24,7 @@ namespace Umbraco.Core.Configuration
///
/// The property type alias.
/// The auto-fill configuration for the specified property alias, or null.
- public static IImagingAutoFillUploadField GetConfig(this ContentSettings contentSettings, string propertyTypeAlias)
+ public static ImagingAutoFillUploadField GetConfig(this ContentSettings contentSettings, string propertyTypeAlias)
{
var autoFillConfigs = contentSettings.Imaging.AutoFillImageProperties;
return autoFillConfigs?.FirstOrDefault(x => x.Alias == propertyTypeAlias);
diff --git a/src/Umbraco.Core/Configuration/Models/ContentErrorPage.cs b/src/Umbraco.Core/Configuration/Models/ContentErrorPage.cs
index 8971dda5cc..6a362c93a3 100644
--- a/src/Umbraco.Core/Configuration/Models/ContentErrorPage.cs
+++ b/src/Umbraco.Core/Configuration/Models/ContentErrorPage.cs
@@ -1,15 +1,30 @@
using System;
+using System.ComponentModel.DataAnnotations;
+using Umbraco.Core.Configuration.Models.Validation;
namespace Umbraco.Core.Configuration.Models
{
- public class ContentErrorPage
+ public class ContentErrorPage : ValidatableEntryBase
{
- //TODO introduce validation, to check only one of key/id/xPath is used.
- public int ContentId { get; }
- public Guid ContentKey { get; }
- public string ContentXPath { get; }
- public bool HasContentId { get; }
- public bool HasContentKey { get; }
+ public int ContentId { get; set; }
+
+ public Guid ContentKey { get; set; }
+
+ public string ContentXPath { get; set; }
+
+ public bool HasContentId => ContentId != 0;
+
+ public bool HasContentKey => ContentKey != Guid.Empty;
+
+ public bool HasContentXPath => !string.IsNullOrEmpty(ContentXPath);
+
+ [Required]
public string Culture { get; set; }
+
+ internal override bool IsValid()
+ {
+ return base.IsValid() &&
+ ((HasContentId ? 1 : 0) + (HasContentKey ? 1 : 0) + (HasContentXPath ? 1 : 0) == 1);
+ }
}
}
diff --git a/src/Umbraco.Core/Configuration/Models/ContentImagingSettings.cs b/src/Umbraco.Core/Configuration/Models/ContentImagingSettings.cs
index 018936896c..7c1e570426 100644
--- a/src/Umbraco.Core/Configuration/Models/ContentImagingSettings.cs
+++ b/src/Umbraco.Core/Configuration/Models/ContentImagingSettings.cs
@@ -1,7 +1,4 @@
-using System.Collections.Generic;
-using Umbraco.Core.Configuration.UmbracoSettings;
-
-namespace Umbraco.Core.Configuration.Models
+namespace Umbraco.Core.Configuration.Models
{
public class ContentImagingSettings
{
@@ -17,17 +14,8 @@ namespace Umbraco.Core.Configuration.Models
}
};
- public IEnumerable ImageFileTypes { get; set; } = new[] { "jpeg", "jpg", "gif", "bmp", "png", "tiff", "tif" };
+ public string[] ImageFileTypes { get; set; } = new[] { "jpeg", "jpg", "gif", "bmp", "png", "tiff", "tif" };
- public IEnumerable AutoFillImageProperties { get; set; } = DefaultImagingAutoFillUploadField;
-
- private class ImagingAutoFillUploadField : IImagingAutoFillUploadField
- {
- public string Alias { get; set; }
- public string WidthFieldAlias { get; set; }
- public string HeightFieldAlias { get; set; }
- public string LengthFieldAlias { get; set; }
- public string ExtensionFieldAlias { get; set; }
- }
+ public ImagingAutoFillUploadField[] AutoFillImageProperties { get; set; } = DefaultImagingAutoFillUploadField;
}
}
diff --git a/src/Umbraco.Core/Configuration/Models/ContentSettings.cs b/src/Umbraco.Core/Configuration/Models/ContentSettings.cs
index 5158a5c746..65d7855dc7 100644
--- a/src/Umbraco.Core/Configuration/Models/ContentSettings.cs
+++ b/src/Umbraco.Core/Configuration/Models/ContentSettings.cs
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
-using Umbraco.Core.Configuration.UmbracoSettings;
+using Umbraco.Core.Configuration.Models.Validation;
using Umbraco.Core.Macros;
namespace Umbraco.Core.Configuration.Models
@@ -16,7 +16,7 @@ namespace Umbraco.Core.Configuration.Models
public bool ResolveUrlsFromTextString { get; set; } = false;
- public IEnumerable Error404Collection { get; set; } = Array.Empty();
+ public ContentErrorPage[] Error404Collection { get; set; } = Array.Empty();
public string PreviewBadge { get; set; } = DefaultPreviewBadge;
diff --git a/src/Umbraco.Core/Configuration/Models/HostingSettings.cs b/src/Umbraco.Core/Configuration/Models/HostingSettings.cs
index 0863181922..b003315c56 100644
--- a/src/Umbraco.Core/Configuration/Models/HostingSettings.cs
+++ b/src/Umbraco.Core/Configuration/Models/HostingSettings.cs
@@ -1,4 +1,6 @@
-namespace Umbraco.Core.Configuration.Models
+using System;
+
+namespace Umbraco.Core.Configuration.Models
{
public class HostingSettings
{
diff --git a/src/Umbraco.Core/Configuration/Models/ImagingAutoFillUploadField.cs b/src/Umbraco.Core/Configuration/Models/ImagingAutoFillUploadField.cs
new file mode 100644
index 0000000000..f58e2bb4f8
--- /dev/null
+++ b/src/Umbraco.Core/Configuration/Models/ImagingAutoFillUploadField.cs
@@ -0,0 +1,23 @@
+using System.ComponentModel.DataAnnotations;
+using Umbraco.Core.Configuration.Models.Validation;
+
+namespace Umbraco.Core.Configuration.Models
+{
+ public class ImagingAutoFillUploadField : ValidatableEntryBase
+ {
+ [Required]
+ public string Alias { get; set; }
+
+ [Required]
+ public string WidthFieldAlias { get; set; }
+
+ [Required]
+ public string HeightFieldAlias { get; set; }
+
+ [Required]
+ public string LengthFieldAlias { get; set; }
+
+ [Required]
+ public string ExtensionFieldAlias { get; set; }
+ }
+}
diff --git a/src/Umbraco.Core/Configuration/Models/ModelsBuilderConfig.cs b/src/Umbraco.Core/Configuration/Models/ModelsBuilderSettings.cs
similarity index 98%
rename from src/Umbraco.Core/Configuration/Models/ModelsBuilderConfig.cs
rename to src/Umbraco.Core/Configuration/Models/ModelsBuilderSettings.cs
index e99557755c..414165d2e4 100644
--- a/src/Umbraco.Core/Configuration/Models/ModelsBuilderConfig.cs
+++ b/src/Umbraco.Core/Configuration/Models/ModelsBuilderSettings.cs
@@ -5,7 +5,7 @@ namespace Umbraco.Core.Configuration.Models
///
/// Represents the models builder configuration.
///
- public class ModelsBuilderConfig
+ public class ModelsBuilderSettings
{
public static string DefaultModelsDirectory => "~/App_Data/Models";
diff --git a/src/Umbraco.Core/Configuration/Models/NuCacheSettings.cs b/src/Umbraco.Core/Configuration/Models/NuCacheSettings.cs
index a2bc7d3561..89a726f30a 100644
--- a/src/Umbraco.Core/Configuration/Models/NuCacheSettings.cs
+++ b/src/Umbraco.Core/Configuration/Models/NuCacheSettings.cs
@@ -2,6 +2,6 @@
{
public class NuCacheSettings
{
- public string BTreeBlockSize { get; set; }
+ public int? BTreeBlockSize { get; set; }
}
}
diff --git a/src/Umbraco.Core/Configuration/Models/SmtpSettings.cs b/src/Umbraco.Core/Configuration/Models/SmtpSettings.cs
index a507f8a62f..7c19f28d87 100644
--- a/src/Umbraco.Core/Configuration/Models/SmtpSettings.cs
+++ b/src/Umbraco.Core/Configuration/Models/SmtpSettings.cs
@@ -1,9 +1,14 @@
-using System.Net.Mail;
+using System;
+using System.ComponentModel.DataAnnotations;
+using System.Net.Mail;
+using Umbraco.Core.Configuration.Models.Validation;
namespace Umbraco.Core.Configuration.Models
{
- public class SmtpSettings
+ public class SmtpSettings : ValidatableEntryBase
{
+ [Required]
+ [EmailAddress]
public string From { get; set; }
public string Host { get; set; }
@@ -12,7 +17,7 @@ namespace Umbraco.Core.Configuration.Models
public string PickupDirectoryLocation { get; set; }
- public SmtpDeliveryMethod DeliveryMethod { get; set; }
+ public SmtpDeliveryMethod DeliveryMethod { get; set; } = SmtpDeliveryMethod.Network;
public string Username { get; set; }
diff --git a/src/Umbraco.Core/Configuration/Models/Validation/ConfigurationValidatorBase.cs b/src/Umbraco.Core/Configuration/Models/Validation/ConfigurationValidatorBase.cs
new file mode 100644
index 0000000000..fe8d077166
--- /dev/null
+++ b/src/Umbraco.Core/Configuration/Models/Validation/ConfigurationValidatorBase.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Umbraco.Core.Configuration.Models.Validation
+{
+ public abstract class ConfigurationValidatorBase
+ {
+ public bool ValidateStringIsOneOfValidValues(string configPath, string value, IEnumerable validValues, out string message)
+ {
+ if (!validValues.InvariantContains(value))
+ {
+ message = $"Configuration entry {configPath} contains an invalid value '{value}', it should be one of the following: '{string.Join(", ", validValues)}'.";
+ return false;
+ }
+
+ message = string.Empty;
+ return true;
+ }
+
+ public bool ValidateCollection(string configPath, IEnumerable values, string validationDescription, out string message)
+ {
+ if (values.Any(x => !x.IsValid()))
+ {
+ message = $"Configuration entry {configPath} contains one or more invalid values. {validationDescription}.";
+ return false;
+ }
+
+ message = string.Empty;
+ return true;
+ }
+
+ public bool ValidateOptionalEntry(string configPath, ValidatableEntryBase value, string validationDescription, out string message)
+ {
+ if (value != null && !value.IsValid())
+ {
+ message = $"Configuration entry {configPath} contains one or more invalid values. {validationDescription}.";
+ return false;
+ }
+
+ message = string.Empty;
+ return true;
+ }
+ }
+}
diff --git a/src/Umbraco.Core/Configuration/Models/Validation/ContentSettingsValidator.cs b/src/Umbraco.Core/Configuration/Models/Validation/ContentSettingsValidator.cs
new file mode 100644
index 0000000000..9ed22f922e
--- /dev/null
+++ b/src/Umbraco.Core/Configuration/Models/Validation/ContentSettingsValidator.cs
@@ -0,0 +1,35 @@
+using System.Collections.Generic;
+using Microsoft.Extensions.Options;
+using Umbraco.Core.Macros;
+
+namespace Umbraco.Core.Configuration.Models.Validation
+{
+ public class ContentSettingsValidator : ConfigurationValidatorBase, IValidateOptions
+ {
+ public ValidateOptionsResult Validate(string name, ContentSettings options)
+ {
+ string message;
+ if (!ValidateError404Collection(options.Error404Collection, out message))
+ {
+ return ValidateOptionsResult.Fail(message);
+ }
+
+ if (!ValidateAutoFillImageProperties(options.Imaging.AutoFillImageProperties, out message))
+ {
+ return ValidateOptionsResult.Fail(message);
+ }
+
+ return ValidateOptionsResult.Success;
+ }
+
+ private bool ValidateError404Collection(IEnumerable values, out string message)
+ {
+ return ValidateCollection($"{Constants.Configuration.ConfigContent}:{nameof(ContentSettings.Error404Collection)}", values, "Culture and one and only one of ContentId, ContentKey and ContentXPath must be specified for each entry", out message);
+ }
+
+ private bool ValidateAutoFillImageProperties(IEnumerable values, out string message)
+ {
+ return ValidateCollection($"{Constants.Configuration.ConfigContent}:{nameof(ContentSettings.Imaging)}:{nameof(ContentSettings.Imaging.AutoFillImageProperties)}", values, "Alias, WidthFieldAlias, HeightFieldAlias, LengthFieldAlias and ExtensionFieldAlias must be specified for each entry", out message);
+ }
+ }
+}
diff --git a/src/Umbraco.Core/Configuration/Models/Validation/GlobalSettingsValidator.cs b/src/Umbraco.Core/Configuration/Models/Validation/GlobalSettingsValidator.cs
new file mode 100644
index 0000000000..ca3fee7999
--- /dev/null
+++ b/src/Umbraco.Core/Configuration/Models/Validation/GlobalSettingsValidator.cs
@@ -0,0 +1,23 @@
+using Microsoft.Extensions.Options;
+
+namespace Umbraco.Core.Configuration.Models.Validation
+{
+ public class GlobalSettingsValidator
+ : ConfigurationValidatorBase, IValidateOptions
+ {
+ public ValidateOptionsResult Validate(string name, GlobalSettings options)
+ {
+ if (!ValidateSmtpSetting(options.Smtp, out var message))
+ {
+ return ValidateOptionsResult.Fail(message);
+ }
+
+ return ValidateOptionsResult.Success;
+ }
+
+ private bool ValidateSmtpSetting(SmtpSettings value, out string message)
+ {
+ return ValidateOptionalEntry($"{Constants.Configuration.ConfigGlobal}:{nameof(GlobalSettings.Smtp)}", value, "A valid From email address is required", out message);
+ }
+ }
+}
diff --git a/src/Umbraco.Core/Configuration/Models/Validation/RequestHandlerSettingsValidator.cs b/src/Umbraco.Core/Configuration/Models/Validation/RequestHandlerSettingsValidator.cs
new file mode 100644
index 0000000000..305fe812f8
--- /dev/null
+++ b/src/Umbraco.Core/Configuration/Models/Validation/RequestHandlerSettingsValidator.cs
@@ -0,0 +1,23 @@
+using Microsoft.Extensions.Options;
+
+namespace Umbraco.Core.Configuration.Models.Validation
+{
+ public class RequestHandlerSettingsValidator : ConfigurationValidatorBase, IValidateOptions
+ {
+ public ValidateOptionsResult Validate(string name, RequestHandlerSettings options)
+ {
+ if (!ValidateConvertUrlsToAscii(options.ConvertUrlsToAscii, out var message))
+ {
+ return ValidateOptionsResult.Fail(message);
+ }
+
+ return ValidateOptionsResult.Success;
+ }
+
+ private bool ValidateConvertUrlsToAscii(string value, out string message)
+ {
+ var validValues = new[] { "try", "true", "false" };
+ return ValidateStringIsOneOfValidValues($"{Constants.Configuration.ConfigRequestHandler}:{nameof(RequestHandlerSettings.ConvertUrlsToAscii)}", value, validValues, out message);
+ }
+ }
+}
diff --git a/src/Umbraco.Core/Configuration/Models/Validation/ValidatableEntryBase.cs b/src/Umbraco.Core/Configuration/Models/Validation/ValidatableEntryBase.cs
new file mode 100644
index 0000000000..32e3c3270b
--- /dev/null
+++ b/src/Umbraco.Core/Configuration/Models/Validation/ValidatableEntryBase.cs
@@ -0,0 +1,15 @@
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+
+namespace Umbraco.Core.Configuration.Models.Validation
+{
+ public abstract class ValidatableEntryBase
+ {
+ internal virtual bool IsValid()
+ {
+ var ctx = new ValidationContext(this);
+ var results = new List();
+ return Validator.TryValidateObject(this, ctx, results, true);
+ }
+ }
+}
diff --git a/src/Umbraco.Core/Configuration/Models/WebRoutingSettings.cs b/src/Umbraco.Core/Configuration/Models/WebRoutingSettings.cs
index 7e0c4d5d8c..476d58c913 100644
--- a/src/Umbraco.Core/Configuration/Models/WebRoutingSettings.cs
+++ b/src/Umbraco.Core/Configuration/Models/WebRoutingSettings.cs
@@ -16,7 +16,7 @@ namespace Umbraco.Core.Configuration.Models
public bool DisableRedirectUrlTracking { get; set; } = false;
- public string UrlProviderMode { get; set; } = UrlMode.Auto.ToString();
+ public UrlMode UrlProviderMode { get; set; } = UrlMode.Auto;
public string UmbracoApplicationUrl { get; set; }
}
diff --git a/src/Umbraco.Core/Configuration/ModelsBuilderConfigExtensions.cs b/src/Umbraco.Core/Configuration/ModelsBuilderConfigExtensions.cs
index edf068e16f..ef80796c8b 100644
--- a/src/Umbraco.Core/Configuration/ModelsBuilderConfigExtensions.cs
+++ b/src/Umbraco.Core/Configuration/ModelsBuilderConfigExtensions.cs
@@ -10,7 +10,7 @@ namespace Umbraco.Core.Configuration
{
private static string _modelsDirectoryAbsolute = null;
- public static string ModelsDirectoryAbsolute(this ModelsBuilderConfig modelsBuilderConfig, IHostingEnvironment hostingEnvironment)
+ public static string ModelsDirectoryAbsolute(this ModelsBuilderSettings modelsBuilderConfig, IHostingEnvironment hostingEnvironment)
{
if (_modelsDirectoryAbsolute is null)
{
diff --git a/src/Umbraco.Core/Constants-Configuration.cs b/src/Umbraco.Core/Constants-Configuration.cs
index 86a02affb6..c06ec8f1ec 100644
--- a/src/Umbraco.Core/Constants-Configuration.cs
+++ b/src/Umbraco.Core/Constants-Configuration.cs
@@ -11,11 +11,30 @@
/// ":" is used as marker for nested objects in json. E.g. "Umbraco:CMS:" = {"Umbraco":{"CMS":{....}}
///
public const string ConfigPrefix = "Umbraco:CMS:";
- public const string ConfigSecurityPrefix = ConfigPrefix+"Security:";
- public const string ConfigGlobalPrefix = ConfigPrefix + "Global:";
- public const string ConfigModelsBuilderPrefix = ConfigPrefix+"ModelsBuilder:";
- public const string ConfigRuntimeMinification = ConfigPrefix+"RuntimeMinification";
- public const string ConfigRuntimeMinificationVersion = ConfigRuntimeMinification+":Version";
+ public const string ConfigActiveDirectory = ConfigPrefix + "ActiveDirectory";
+ public const string ConfigContent = ConfigPrefix + "Content";
+ public const string ConfigCoreDebug = ConfigPrefix + "Core:Debug";
+ public const string ConfigExceptionFilter = ConfigPrefix + "ExceptionFilter";
+ public const string ConfigGlobal = ConfigPrefix + "Global";
+ public const string ConfigHealthChecks = ConfigPrefix + "HealthChecks";
+ public const string ConfigHosting = ConfigPrefix + "Hosting";
+ public const string ConfigImaging = ConfigPrefix + "Imaging";
+ public const string ConfigExamine = ConfigPrefix + "Examine";
+ public const string ConfigKeepAlive = ConfigPrefix + "KeepAlive";
+ public const string ConfigLogging = ConfigPrefix + "Logging";
+ public const string ConfigMemberPassword = ConfigPrefix + "Security:MemberPassword";
+ public const string ConfigModelsBuilder = ConfigPrefix + "ModelsBuilder";
+ public const string ConfigNuCache = ConfigPrefix + "NuCache";
+ public const string ConfigRequestHandler = ConfigPrefix + "RequestHandler";
+ public const string ConfigRuntime = ConfigPrefix + "Runtime";
+ public const string ConfigSecurity = ConfigPrefix + "Security";
+ public const string ConfigTours = ConfigPrefix + "Tours";
+ public const string ConfigTypeFinder = ConfigPrefix + "TypeFinder";
+ public const string ConfigWebRouting = ConfigPrefix + "WebRouting";
+ public const string ConfigUserPassword = ConfigPrefix + "Security:UserPassword";
+
+ public const string ConfigRuntimeMinification = ConfigPrefix + "RuntimeMinification";
+ public const string ConfigRuntimeMinificationVersion = ConfigRuntimeMinification + ":Version";
}
}
}
diff --git a/src/Umbraco.Core/Constants-Web.cs b/src/Umbraco.Core/Constants-Web.cs
index d18e23a6c3..d0ae5550ca 100644
--- a/src/Umbraco.Core/Constants-Web.cs
+++ b/src/Umbraco.Core/Constants-Web.cs
@@ -51,6 +51,7 @@
public const string BackOfficePathSegment = "BackOffice"; // The path segment prefix for all back office controllers
public const string BackOfficeArea = "UmbracoBackOffice"; // Used for area routes of non-api controllers
public const string BackOfficeApiArea = "UmbracoApi"; // Same name as v8 so all routing remains the same
+ public const string BackOfficeTreeArea = "UmbracoTrees"; // Same name as v8 so all routing remains the same
}
}
}
diff --git a/src/Umbraco.Core/Logging/ILoggingConfiguration.cs b/src/Umbraco.Core/Logging/ILoggingConfiguration.cs
index 47e2d8fa7c..d21a08e688 100644
--- a/src/Umbraco.Core/Logging/ILoggingConfiguration.cs
+++ b/src/Umbraco.Core/Logging/ILoggingConfiguration.cs
@@ -7,7 +7,5 @@
/// The physical path where logs are stored
///
string LogDirectory { get; }
- string LogConfigurationFile { get; }
- string UserLogConfigurationFile { get; }
}
}
diff --git a/src/Umbraco.Core/Logging/LoggingConfiguration.cs b/src/Umbraco.Core/Logging/LoggingConfiguration.cs
index c657c9d430..ecd806211c 100644
--- a/src/Umbraco.Core/Logging/LoggingConfiguration.cs
+++ b/src/Umbraco.Core/Logging/LoggingConfiguration.cs
@@ -4,17 +4,11 @@ namespace Umbraco.Core.Logging
{
public class LoggingConfiguration : ILoggingConfiguration
{
- public LoggingConfiguration(string logDirectory, string logConfigurationFile, string userLogConfigurationFile)
+ public LoggingConfiguration(string logDirectory)
{
LogDirectory = logDirectory ?? throw new ArgumentNullException(nameof(logDirectory));
- LogConfigurationFile = logConfigurationFile ?? throw new ArgumentNullException(nameof(logConfigurationFile));
- UserLogConfigurationFile = userLogConfigurationFile ?? throw new ArgumentNullException(nameof(userLogConfigurationFile));
}
public string LogDirectory { get; }
-
- public string LogConfigurationFile { get; }
-
- public string UserLogConfigurationFile { get; }
}
}
diff --git a/src/Umbraco.Core/Media/IImageUrlGenerator.cs b/src/Umbraco.Core/Media/IImageUrlGenerator.cs
index f9e67cdd2b..7c77a34388 100644
--- a/src/Umbraco.Core/Media/IImageUrlGenerator.cs
+++ b/src/Umbraco.Core/Media/IImageUrlGenerator.cs
@@ -1,9 +1,12 @@
-using Umbraco.Core.Models;
+using System.Collections.Generic;
+using Umbraco.Core.Models;
namespace Umbraco.Core.Media
{
public interface IImageUrlGenerator
{
+ IEnumerable SupportedImageFileTypes { get; }
+
string GetImageUrl(ImageUrlGenerationOptions options);
}
}
diff --git a/src/Umbraco.Core/Media/ImageUrlGeneratorExtensions.cs b/src/Umbraco.Core/Media/ImageUrlGeneratorExtensions.cs
new file mode 100644
index 0000000000..902f84331b
--- /dev/null
+++ b/src/Umbraco.Core/Media/ImageUrlGeneratorExtensions.cs
@@ -0,0 +1,21 @@
+using System;
+
+namespace Umbraco.Core.Media
+{
+ public static class ImageUrlGeneratorExtensions
+ {
+ ///
+ /// Gets a value indicating whether the file extension corresponds to a supported image.
+ ///
+ /// The image URL generator implementation that provides detail on which image extension sare supported.
+ /// The file extension.
+ /// A value indicating whether the file extension corresponds to an image.
+ public static bool IsSupportedImageFormat(this IImageUrlGenerator imageUrlGenerator, string extension)
+ {
+ if (imageUrlGenerator == null) throw new ArgumentNullException(nameof(imageUrlGenerator));
+ if (extension == null) return false;
+ extension = extension.TrimStart('.');
+ return imageUrlGenerator.SupportedImageFileTypes.InvariantContains(extension);
+ }
+ }
+}
diff --git a/src/Umbraco.Core/Routing/UrlProvider.cs b/src/Umbraco.Core/Routing/UrlProvider.cs
index 69d2e00276..9dd4a413a2 100644
--- a/src/Umbraco.Core/Routing/UrlProvider.cs
+++ b/src/Umbraco.Core/Routing/UrlProvider.cs
@@ -31,16 +31,9 @@ namespace Umbraco.Web.Routing
_urlProviders = urlProviders;
_mediaUrlProviders = mediaUrlProviders;
_variationContextAccessor = variationContextAccessor ?? throw new ArgumentNullException(nameof(variationContextAccessor));
- var provider = UrlMode.Auto;
- Mode = provider;
-
- if (Enum.TryParse(routingSettings.Value.UrlProviderMode, out provider))
- {
- Mode = provider;
- }
+ Mode = routingSettings.Value.UrlProviderMode;
}
-
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
private readonly IEnumerable _urlProviders;
private readonly IEnumerable _mediaUrlProviders;
diff --git a/src/Umbraco.Infrastructure/Composing/HostBuilderExtensions.cs b/src/Umbraco.Infrastructure/Composing/HostBuilderExtensions.cs
index f6d980f62a..ad7c75b94f 100644
--- a/src/Umbraco.Infrastructure/Composing/HostBuilderExtensions.cs
+++ b/src/Umbraco.Infrastructure/Composing/HostBuilderExtensions.cs
@@ -26,7 +26,6 @@ namespace Umbraco.Core.Composing
///
///
public static IHostBuilder UseUmbraco(this IHostBuilder builder, UmbracoServiceProviderFactory umbracoServiceProviderFactory)
- => builder.UseServiceProviderFactory(umbracoServiceProviderFactory)
- .UseSerilog();
+ => builder.UseServiceProviderFactory(umbracoServiceProviderFactory);
}
}
diff --git a/src/Umbraco.Infrastructure/Logging/Serilog/LoggerConfigExtensions.cs b/src/Umbraco.Infrastructure/Logging/Serilog/LoggerConfigExtensions.cs
index f2e028e6de..84270b95bf 100644
--- a/src/Umbraco.Infrastructure/Logging/Serilog/LoggerConfigExtensions.cs
+++ b/src/Umbraco.Infrastructure/Logging/Serilog/LoggerConfigExtensions.cs
@@ -7,7 +7,6 @@ using Serilog.Core;
using Serilog.Events;
using Serilog.Formatting;
using Serilog.Formatting.Compact;
-using Umbraco.Core.IO;
using Umbraco.Core.Hosting;
using Umbraco.Core.Logging.Serilog.Enrichers;
@@ -48,6 +47,11 @@ namespace Umbraco.Core.Logging.Serilog
.Enrich.With()
.Enrich.FromLogContext(); // allows us to dynamically enrich
+
+ logConfig.WriteTo.UmbracoFile(
+ Path.Combine(loggingConfiguration.LogDirectory, $"UmbracoTraceLog.{Environment.MachineName}..json")
+ );
+
return logConfig;
}
@@ -61,7 +65,7 @@ namespace Umbraco.Core.Logging.Serilog
public static LoggerConfiguration OutputDefaultTextFile(
this LoggerConfiguration logConfig,
IHostingEnvironment hostingEnvironment,
- ILoggingConfiguration loggingConfiguration, LogEventLevel minimumLevel = LogEventLevel.Verbose, int? retainedFileCount = null)
+ LogEventLevel minimumLevel = LogEventLevel.Verbose)
{
//Main .txt logfile - in similar format to older Log4Net output
//Ends with ..txt as Date is inserted before file extension substring
@@ -79,18 +83,25 @@ namespace Umbraco.Core.Logging.Serilog
///
/// Used in config - If renamed or moved to other assembly the config file also has be updated.
///
- public static LoggerConfiguration File(this LoggerSinkConfiguration configuration, ITextFormatter formatter,
+ public static LoggerConfiguration UmbracoFile(this LoggerSinkConfiguration configuration,
string path,
+ ITextFormatter formatter = null,
LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose,
LoggingLevelSwitch levelSwitch = null,
long? fileSizeLimitBytes = 1073741824,
TimeSpan? flushToDiskInterval = null,
- RollingInterval rollingInterval = RollingInterval.Infinite,
+ RollingInterval rollingInterval = RollingInterval.Day,
bool rollOnFileSizeLimit = false,
int? retainedFileCountLimit = 31,
Encoding encoding = null
)
{
+
+ if (formatter is null)
+ {
+ formatter = new CompactJsonFormatter();
+ }
+
return configuration.Async(
asyncConfiguration => asyncConfiguration.Map(AppDomainId, (_,mapConfiguration) =>
mapConfiguration.File(
@@ -136,34 +147,5 @@ namespace Umbraco.Core.Logging.Serilog
return logConfig;
}
- ///
- /// Reads settings from /config/serilog.config
- /// That allows the main logging pipeline to be configured
- ///
- /// A Serilog LoggerConfiguration
- ///
- public static LoggerConfiguration ReadFromConfigFile(this LoggerConfiguration logConfig, ILoggingConfiguration loggingConfiguration)
- {
- //Read from main serilog.config file
- logConfig.ReadFrom.AppSettings(filePath: loggingConfiguration.LogConfigurationFile);
-
- return logConfig;
- }
-
- ///
- /// Reads settings from /config/serilog.user.config
- /// That allows a separate logging pipeline to be configured that will not affect the main Umbraco log
- ///
- /// A Serilog LoggerConfiguration
- ///
- public static LoggerConfiguration ReadFromUserConfigFile(this LoggerConfiguration logConfig, ILoggingConfiguration loggingConfiguration)
- {
- //A nested logger - where any user configured sinks via config can not effect the main 'umbraco' logger above
- logConfig.WriteTo.Logger(cfg =>
- cfg.ReadFrom.AppSettings(filePath: loggingConfiguration.UserLogConfigurationFile));
-
- return logConfig;
- }
-
}
}
diff --git a/src/Umbraco.Infrastructure/Logging/Serilog/SerilogLogger.cs b/src/Umbraco.Infrastructure/Logging/Serilog/SerilogLogger.cs
index 38af9554ab..7b8b83c59a 100644
--- a/src/Umbraco.Infrastructure/Logging/Serilog/SerilogLogger.cs
+++ b/src/Umbraco.Infrastructure/Logging/Serilog/SerilogLogger.cs
@@ -1,7 +1,9 @@
using System;
using System.IO;
+using Microsoft.Extensions.Configuration;
using Serilog;
using Serilog.Events;
+using Serilog.Extensions.Logging;
using Umbraco.Core.Hosting;
namespace Umbraco.Core.Logging.Serilog
@@ -35,13 +37,14 @@ namespace Umbraco.Core.Logging.Serilog
/// Creates a logger with some pre-defined configuration and remainder from config file
///
/// Used by UmbracoApplicationBase to get its logger.
- public static SerilogLogger CreateWithDefaultConfiguration(IHostingEnvironment hostingEnvironment, ILoggingConfiguration loggingConfiguration)
+ public static SerilogLogger CreateWithDefaultConfiguration(
+ IHostingEnvironment hostingEnvironment,
+ ILoggingConfiguration loggingConfiguration,
+ IConfiguration configuration)
{
- var loggerConfig = new LoggerConfiguration();
- loggerConfig
+ var loggerConfig = new LoggerConfiguration()
.MinimalConfiguration(hostingEnvironment, loggingConfiguration)
- .ReadFromConfigFile(loggingConfiguration)
- .ReadFromUserConfigFile(loggingConfiguration);
+ .ReadFrom.Configuration(configuration);
return new SerilogLogger(loggerConfig);
}
@@ -83,7 +86,7 @@ namespace Umbraco.Core.Logging.Serilog
///
public void Fatal(Type reporting, Exception exception, string message)
{
- var logger = LoggerFor(reporting);
+ var logger = LoggerFor(reporting);
logger.Fatal(exception, message);
}
@@ -91,7 +94,7 @@ namespace Umbraco.Core.Logging.Serilog
public void Fatal(Type reporting, Exception exception)
{
var logger = LoggerFor(reporting);
- var message = "Exception.";
+ var message = "Exception.";
logger.Fatal(exception, message);
}
@@ -110,14 +113,14 @@ namespace Umbraco.Core.Logging.Serilog
///
public void Fatal(Type reporting, Exception exception, string messageTemplate, params object[] propertyValues)
{
- var logger = LoggerFor(reporting);
+ var logger = LoggerFor(reporting);
logger.Fatal(exception, messageTemplate, propertyValues);
}
///
public void Error(Type reporting, Exception exception, string message)
{
- var logger = LoggerFor(reporting);
+ var logger = LoggerFor(reporting);
logger.Error(exception, message);
}
diff --git a/src/Umbraco.Infrastructure/Logging/Viewer/LogViewerComposer.cs b/src/Umbraco.Infrastructure/Logging/Viewer/LogViewerComposer.cs
index 0909ec67ad..d340bb817f 100644
--- a/src/Umbraco.Infrastructure/Logging/Viewer/LogViewerComposer.cs
+++ b/src/Umbraco.Infrastructure/Logging/Viewer/LogViewerComposer.cs
@@ -11,16 +11,6 @@ namespace Umbraco.Core.Logging.Viewer
{
public void Compose(Composition composition)
{
-
-
- composition.RegisterUnique(factory =>
- {
- var hostingEnvironment = factory.GetInstance();
- return new LoggingConfiguration(
- Path.Combine(hostingEnvironment.ApplicationPhysicalPath, "App_Data", "Logs"),
- Path.Combine(hostingEnvironment.ApplicationPhysicalPath, "config", "serilog.config"),
- Path.Combine(hostingEnvironment.ApplicationPhysicalPath, "config", "serilog.user.config"));
- });
composition.RegisterUnique();
composition.SetLogViewer();
composition.RegisterUnique(factory =>
diff --git a/src/Umbraco.Infrastructure/Media/ImageSharpImageUrlGenerator.cs b/src/Umbraco.Infrastructure/Media/ImageSharpImageUrlGenerator.cs
index 48ff16f85b..cfe542badc 100644
--- a/src/Umbraco.Infrastructure/Media/ImageSharpImageUrlGenerator.cs
+++ b/src/Umbraco.Infrastructure/Media/ImageSharpImageUrlGenerator.cs
@@ -1,4 +1,5 @@
-using System.Globalization;
+using System.Collections.Generic;
+using System.Globalization;
using System.Text;
using Umbraco.Core;
using Umbraco.Core.Media;
@@ -9,6 +10,8 @@ namespace Umbraco.Infrastructure.Media
{
public class ImageSharpImageUrlGenerator : IImageUrlGenerator
{
+ public IEnumerable SupportedImageFileTypes => new[] { "jpeg", "jpg", "gif", "bmp", "png" };
+
public string GetImageUrl(ImageUrlGenerationOptions options)
{
if (options == null) return null;
diff --git a/src/Umbraco.Infrastructure/Media/UploadAutoFillProperties.cs b/src/Umbraco.Infrastructure/Media/UploadAutoFillProperties.cs
index 762e418441..482fa0a6b8 100644
--- a/src/Umbraco.Infrastructure/Media/UploadAutoFillProperties.cs
+++ b/src/Umbraco.Infrastructure/Media/UploadAutoFillProperties.cs
@@ -1,13 +1,11 @@
using System;
using System.Drawing;
using System.IO;
-using Microsoft.Extensions.Options;
using Umbraco.Core;
-using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.Models;
-using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
+using Umbraco.Core.Media;
using Umbraco.Core.Models;
namespace Umbraco.Web.Media
@@ -19,16 +17,16 @@ namespace Umbraco.Web.Media
{
private readonly IMediaFileSystem _mediaFileSystem;
private readonly ILogger _logger;
- private readonly ContentSettings _contentSettings;
+ private readonly IImageUrlGenerator _imageUrlGenerator;
public UploadAutoFillProperties(
IMediaFileSystem mediaFileSystem,
ILogger logger,
- IOptions contentSettings)
+ IImageUrlGenerator imageUrlGenerator)
{
_mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
- _contentSettings = contentSettings.Value ?? throw new ArgumentNullException(nameof(contentSettings));
+ _imageUrlGenerator = imageUrlGenerator ?? throw new ArgumentNullException(nameof(imageUrlGenerator));
}
///
@@ -38,7 +36,7 @@ namespace Umbraco.Web.Media
/// The auto-fill configuration.
/// Variation language.
/// Variation segment.
- public void Reset(IContentBase content, IImagingAutoFillUploadField autoFillConfig, string culture, string segment)
+ public void Reset(IContentBase content, ImagingAutoFillUploadField autoFillConfig, string culture, string segment)
{
if (content == null) throw new ArgumentNullException(nameof(content));
if (autoFillConfig == null) throw new ArgumentNullException(nameof(autoFillConfig));
@@ -55,7 +53,7 @@ namespace Umbraco.Web.Media
/// The parameter is the path relative to the filesystem.
/// Variation language.
/// Variation segment.
- public void Populate(IContentBase content, IImagingAutoFillUploadField autoFillConfig, string filepath, string culture, string segment)
+ public void Populate(IContentBase content, ImagingAutoFillUploadField autoFillConfig, string filepath, string culture, string segment)
{
if (content == null) throw new ArgumentNullException(nameof(content));
if (autoFillConfig == null) throw new ArgumentNullException(nameof(autoFillConfig));
@@ -73,7 +71,7 @@ namespace Umbraco.Web.Media
using (var filestream = _mediaFileSystem.OpenFile(filepath))
{
var extension = (Path.GetExtension(filepath) ?? "").TrimStart('.');
- var size = _contentSettings.IsImageFile(extension) ? (Size?)ImageHelper.GetDimensions(filestream) : null;
+ var size = _imageUrlGenerator.IsSupportedImageFormat(extension) ? (Size?)ImageHelper.GetDimensions(filestream) : null;
SetProperties(content, autoFillConfig, size, filestream.Length, extension, culture, segment);
}
}
@@ -94,7 +92,7 @@ namespace Umbraco.Web.Media
/// The stream containing the file data.
/// Variation language.
/// Variation segment.
- public void Populate(IContentBase content, IImagingAutoFillUploadField autoFillConfig, string filepath, Stream filestream, string culture, string segment)
+ public void Populate(IContentBase content, ImagingAutoFillUploadField autoFillConfig, string filepath, Stream filestream, string culture, string segment)
{
if (content == null) throw new ArgumentNullException(nameof(content));
if (autoFillConfig == null) throw new ArgumentNullException(nameof(autoFillConfig));
@@ -107,12 +105,12 @@ namespace Umbraco.Web.Media
else
{
var extension = (Path.GetExtension(filepath) ?? "").TrimStart('.');
- var size = _contentSettings.IsImageFile(extension) ? (Size?)ImageHelper.GetDimensions(filestream) : null;
+ var size = _imageUrlGenerator.IsSupportedImageFormat(extension) ? (Size?)ImageHelper.GetDimensions(filestream) : null;
SetProperties(content, autoFillConfig, size, filestream.Length, extension, culture, segment);
}
}
- private static void SetProperties(IContentBase content, IImagingAutoFillUploadField autoFillConfig, Size? size, long length, string extension, string culture, string segment)
+ private static void SetProperties(IContentBase content, ImagingAutoFillUploadField autoFillConfig, Size? size, long length, string extension, string culture, string segment)
{
if (content == null) throw new ArgumentNullException(nameof(content));
if (autoFillConfig == null) throw new ArgumentNullException(nameof(autoFillConfig));
@@ -130,7 +128,7 @@ namespace Umbraco.Web.Media
content.Properties[autoFillConfig.ExtensionFieldAlias].SetValue(extension, culture, segment);
}
- private static void ResetProperties(IContentBase content, IImagingAutoFillUploadField autoFillConfig, string culture, string segment)
+ private static void ResetProperties(IContentBase content, ImagingAutoFillUploadField autoFillConfig, string culture, string segment)
{
if (content == null) throw new ArgumentNullException(nameof(content));
if (autoFillConfig == null) throw new ArgumentNullException(nameof(autoFillConfig));
diff --git a/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs
index d4c5130b21..ab0b943a2f 100644
--- a/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs
+++ b/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs
@@ -7,6 +7,7 @@ using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.Models;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
+using Umbraco.Core.Media;
using Umbraco.Core.Models;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
@@ -37,7 +38,8 @@ namespace Umbraco.Web.PropertyEditors
IDataTypeService dataTypeService,
ILocalizationService localizationService,
ILocalizedTextService localizedTextService,
- IShortStringHelper shortStringHelper)
+ IShortStringHelper shortStringHelper,
+ UploadAutoFillProperties uploadAutoFillProperties)
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{
_mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem));
@@ -45,7 +47,7 @@ namespace Umbraco.Web.PropertyEditors
_dataTypeService = dataTypeService;
_localizationService = localizationService;
_localizedTextService = localizedTextService;
- _uploadAutoFillProperties = new UploadAutoFillProperties(_mediaFileSystem, logger, contentSettings);
+ _uploadAutoFillProperties = uploadAutoFillProperties;
}
///
diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs
index 0fea46f2d3..84d85f795c 100644
--- a/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs
+++ b/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs
@@ -9,6 +9,7 @@ using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.Models;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
+using Umbraco.Core.Media;
using Umbraco.Core.Models;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
@@ -33,7 +34,6 @@ namespace Umbraco.Web.PropertyEditors
private readonly IMediaFileSystem _mediaFileSystem;
private readonly ContentSettings _contentSettings;
private readonly IDataTypeService _dataTypeService;
- private readonly ILocalizationService _localizationService;
private readonly IIOHelper _ioHelper;
private readonly UploadAutoFillProperties _autoFillProperties;
@@ -48,17 +48,15 @@ namespace Umbraco.Web.PropertyEditors
ILocalizationService localizationService,
IIOHelper ioHelper,
IShortStringHelper shortStringHelper,
- ILocalizedTextService localizedTextService)
+ ILocalizedTextService localizedTextService,
+ UploadAutoFillProperties uploadAutoFillProperties)
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{
_mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem));
_contentSettings = contentSettings.Value ?? throw new ArgumentNullException(nameof(contentSettings));
- _dataTypeService = dataTypeService;
- _localizationService = localizationService;
- _ioHelper = ioHelper;
-
- // TODO: inject?
- _autoFillProperties = new UploadAutoFillProperties(_mediaFileSystem, logger, contentSettings);
+ _dataTypeService = dataTypeService ?? throw new ArgumentNullException(nameof(dataTypeService));
+ _ioHelper = ioHelper ?? throw new ArgumentNullException(nameof(ioHelper));
+ _autoFillProperties = uploadAutoFillProperties ?? throw new ArgumentNullException(nameof(uploadAutoFillProperties));
}
public bool TryGetMediaPath(string alias, object value, out string mediaPath)
diff --git a/src/Umbraco.Infrastructure/Routing/NotFoundHandlerHelper.cs b/src/Umbraco.Infrastructure/Routing/NotFoundHandlerHelper.cs
index 20fbe9a1ef..459d95466d 100644
--- a/src/Umbraco.Infrastructure/Routing/NotFoundHandlerHelper.cs
+++ b/src/Umbraco.Infrastructure/Routing/NotFoundHandlerHelper.cs
@@ -62,7 +62,7 @@ namespace Umbraco.Web.Routing
}
///
- /// Returns the content id based on the configured IContentErrorPage section
+ /// Returns the content id based on the configured ContentErrorPage section.
///
///
///
diff --git a/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs b/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs
index 3422252842..fdd358e64a 100644
--- a/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs
+++ b/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs
@@ -57,6 +57,7 @@ using IntegerValidator = Umbraco.Core.PropertyEditors.Validators.IntegerValidato
using TextStringValueConverter = Umbraco.Core.PropertyEditors.ValueConverters.TextStringValueConverter;
using Umbraco.Core.Configuration.Models;
using Microsoft.Extensions.Options;
+using Umbraco.Web.Media;
namespace Umbraco.Core.Runtime
{
@@ -371,6 +372,8 @@ namespace Umbraco.Core.Runtime
// Register noop versions for examine to be overridden by examine
composition.RegisterUnique();
composition.RegisterUnique();
+
+ composition.RegisterUnique();
}
}
}
diff --git a/src/Umbraco.Infrastructure/Umbraco.Infrastructure.csproj b/src/Umbraco.Infrastructure/Umbraco.Infrastructure.csproj
index bcd3773ac8..4da891427f 100644
--- a/src/Umbraco.Infrastructure/Umbraco.Infrastructure.csproj
+++ b/src/Umbraco.Infrastructure/Umbraco.Infrastructure.csproj
@@ -34,6 +34,7 @@
+
diff --git a/src/Umbraco.ModelsBuilder.Embedded/BackOffice/ContentTypeModelValidator.cs b/src/Umbraco.ModelsBuilder.Embedded/BackOffice/ContentTypeModelValidator.cs
index 5f806883f0..023911d518 100644
--- a/src/Umbraco.ModelsBuilder.Embedded/BackOffice/ContentTypeModelValidator.cs
+++ b/src/Umbraco.ModelsBuilder.Embedded/BackOffice/ContentTypeModelValidator.cs
@@ -11,7 +11,7 @@ namespace Umbraco.ModelsBuilder.Embedded.BackOffice
// ReSharper disable once UnusedMember.Global - This is typed scanned
public class ContentTypeModelValidator : ContentTypeModelValidatorBase
{
- public ContentTypeModelValidator(IOptions config) : base(config)
+ public ContentTypeModelValidator(IOptions config) : base(config)
{
}
}
diff --git a/src/Umbraco.ModelsBuilder.Embedded/BackOffice/ContentTypeModelValidatorBase.cs b/src/Umbraco.ModelsBuilder.Embedded/BackOffice/ContentTypeModelValidatorBase.cs
index c1684dde7a..0e4cd4f49a 100644
--- a/src/Umbraco.ModelsBuilder.Embedded/BackOffice/ContentTypeModelValidatorBase.cs
+++ b/src/Umbraco.ModelsBuilder.Embedded/BackOffice/ContentTypeModelValidatorBase.cs
@@ -14,9 +14,9 @@ namespace Umbraco.ModelsBuilder.Embedded.BackOffice
where TModel : ContentTypeSave
where TProperty : PropertyTypeBasic
{
- private readonly IOptions _config;
+ private readonly IOptions _config;
- public ContentTypeModelValidatorBase(IOptions config)
+ public ContentTypeModelValidatorBase(IOptions config)
{
_config = config;
}
diff --git a/src/Umbraco.ModelsBuilder.Embedded/BackOffice/DashboardReport.cs b/src/Umbraco.ModelsBuilder.Embedded/BackOffice/DashboardReport.cs
index a0928fafcf..c615559920 100644
--- a/src/Umbraco.ModelsBuilder.Embedded/BackOffice/DashboardReport.cs
+++ b/src/Umbraco.ModelsBuilder.Embedded/BackOffice/DashboardReport.cs
@@ -8,11 +8,11 @@ namespace Umbraco.ModelsBuilder.Embedded.BackOffice
{
internal class DashboardReport
{
- private readonly ModelsBuilderConfig _config;
+ private readonly ModelsBuilderSettings _config;
private readonly OutOfDateModelsStatus _outOfDateModels;
private readonly ModelsGenerationError _mbErrors;
- public DashboardReport(IOptions config, OutOfDateModelsStatus outOfDateModels, ModelsGenerationError mbErrors)
+ public DashboardReport(IOptions config, OutOfDateModelsStatus outOfDateModels, ModelsGenerationError mbErrors)
{
_config = config.Value;
_outOfDateModels = outOfDateModels;
diff --git a/src/Umbraco.ModelsBuilder.Embedded/BackOffice/MediaTypeModelValidator.cs b/src/Umbraco.ModelsBuilder.Embedded/BackOffice/MediaTypeModelValidator.cs
index b6cc135e7c..4ccdc1b362 100644
--- a/src/Umbraco.ModelsBuilder.Embedded/BackOffice/MediaTypeModelValidator.cs
+++ b/src/Umbraco.ModelsBuilder.Embedded/BackOffice/MediaTypeModelValidator.cs
@@ -11,7 +11,7 @@ namespace Umbraco.ModelsBuilder.Embedded.BackOffice
// ReSharper disable once UnusedMember.Global - This is typed scanned
public class MediaTypeModelValidator : ContentTypeModelValidatorBase
{
- public MediaTypeModelValidator(IOptions config) : base(config)
+ public MediaTypeModelValidator(IOptions config) : base(config)
{
}
}
diff --git a/src/Umbraco.ModelsBuilder.Embedded/BackOffice/MemberTypeModelValidator.cs b/src/Umbraco.ModelsBuilder.Embedded/BackOffice/MemberTypeModelValidator.cs
index c930642155..9a735631ff 100644
--- a/src/Umbraco.ModelsBuilder.Embedded/BackOffice/MemberTypeModelValidator.cs
+++ b/src/Umbraco.ModelsBuilder.Embedded/BackOffice/MemberTypeModelValidator.cs
@@ -11,7 +11,7 @@ namespace Umbraco.ModelsBuilder.Embedded.BackOffice
// ReSharper disable once UnusedMember.Global - This is typed scanned
public class MemberTypeModelValidator : ContentTypeModelValidatorBase
{
- public MemberTypeModelValidator(IOptions config) : base(config)
+ public MemberTypeModelValidator(IOptions config) : base(config)
{
}
}
diff --git a/src/Umbraco.ModelsBuilder.Embedded/BackOffice/ModelsBuilderDashboardController.cs b/src/Umbraco.ModelsBuilder.Embedded/BackOffice/ModelsBuilderDashboardController.cs
index 1339c79052..3adbc0df2c 100644
--- a/src/Umbraco.ModelsBuilder.Embedded/BackOffice/ModelsBuilderDashboardController.cs
+++ b/src/Umbraco.ModelsBuilder.Embedded/BackOffice/ModelsBuilderDashboardController.cs
@@ -23,14 +23,14 @@ namespace Umbraco.ModelsBuilder.Embedded.BackOffice
[UmbracoApplicationAuthorize(Core.Constants.Applications.Settings)]
public class ModelsBuilderDashboardController : UmbracoAuthorizedJsonController
{
- private readonly ModelsBuilderConfig _config;
+ private readonly ModelsBuilderSettings _config;
private readonly ModelsGenerator _modelGenerator;
private readonly OutOfDateModelsStatus _outOfDateModels;
private readonly ModelsGenerationError _mbErrors;
private readonly DashboardReport _dashboardReport;
private readonly IHostingEnvironment _hostingEnvironment;
- public ModelsBuilderDashboardController(IOptions config, ModelsGenerator modelsGenerator, OutOfDateModelsStatus outOfDateModels, ModelsGenerationError mbErrors, IHostingEnvironment hostingEnvironment)
+ public ModelsBuilderDashboardController(IOptions config, ModelsGenerator modelsGenerator, OutOfDateModelsStatus outOfDateModels, ModelsGenerationError mbErrors, IHostingEnvironment hostingEnvironment)
{
//_umbracoServices = umbracoServices;
_config = config.Value;
diff --git a/src/Umbraco.ModelsBuilder.Embedded/Building/Builder.cs b/src/Umbraco.ModelsBuilder.Embedded/Building/Builder.cs
index 4c90234fab..aa7ab40ba5 100644
--- a/src/Umbraco.ModelsBuilder.Embedded/Building/Builder.cs
+++ b/src/Umbraco.ModelsBuilder.Embedded/Building/Builder.cs
@@ -66,7 +66,7 @@ namespace Umbraco.ModelsBuilder.Embedded.Building
///
/// The list of models to generate.
/// The models namespace.
- protected Builder(ModelsBuilderConfig config, IList typeModels)
+ protected Builder(ModelsBuilderSettings config, IList typeModels)
{
_typeModels = typeModels ?? throw new ArgumentNullException(nameof(typeModels));
@@ -83,7 +83,7 @@ namespace Umbraco.ModelsBuilder.Embedded.Building
protected Builder()
{ }
- protected ModelsBuilderConfig Config { get; }
+ protected ModelsBuilderSettings Config { get; }
///
/// Prepares generation by processing the result of code parsing.
diff --git a/src/Umbraco.ModelsBuilder.Embedded/Building/ModelsGenerator.cs b/src/Umbraco.ModelsBuilder.Embedded/Building/ModelsGenerator.cs
index 0348c287cd..bc97118ee4 100644
--- a/src/Umbraco.ModelsBuilder.Embedded/Building/ModelsGenerator.cs
+++ b/src/Umbraco.ModelsBuilder.Embedded/Building/ModelsGenerator.cs
@@ -11,11 +11,11 @@ namespace Umbraco.ModelsBuilder.Embedded.Building
public class ModelsGenerator
{
private readonly UmbracoServices _umbracoService;
- private readonly ModelsBuilderConfig _config;
+ private readonly ModelsBuilderSettings _config;
private readonly OutOfDateModelsStatus _outOfDateModels;
private readonly IHostingEnvironment _hostingEnvironment;
- public ModelsGenerator(UmbracoServices umbracoService, IOptions config, OutOfDateModelsStatus outOfDateModels, IHostingEnvironment hostingEnvironment)
+ public ModelsGenerator(UmbracoServices umbracoService, IOptions config, OutOfDateModelsStatus outOfDateModels, IHostingEnvironment hostingEnvironment)
{
_umbracoService = umbracoService;
_config = config.Value;
diff --git a/src/Umbraco.ModelsBuilder.Embedded/Building/TextBuilder.cs b/src/Umbraco.ModelsBuilder.Embedded/Building/TextBuilder.cs
index 607aa129b1..43771eb46a 100644
--- a/src/Umbraco.ModelsBuilder.Embedded/Building/TextBuilder.cs
+++ b/src/Umbraco.ModelsBuilder.Embedded/Building/TextBuilder.cs
@@ -18,7 +18,7 @@ namespace Umbraco.ModelsBuilder.Embedded.Building
/// and the result of code parsing.
///
/// The list of models to generate.
- public TextBuilder(ModelsBuilderConfig config, IList typeModels)
+ public TextBuilder(ModelsBuilderSettings config, IList typeModels)
: base(config, typeModels)
{ }
diff --git a/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComponent.cs b/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComponent.cs
index 1088dfb470..837bf18dae 100644
--- a/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComponent.cs
+++ b/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComponent.cs
@@ -21,7 +21,7 @@ namespace Umbraco.ModelsBuilder.Embedded.Compose
{
internal class ModelsBuilderComponent : IComponent
{
- private readonly ModelsBuilderConfig _config;
+ private readonly ModelsBuilderSettings _config;
private readonly IShortStringHelper _shortStringHelper;
private readonly LiveModelsProvider _liveModelsProvider;
private readonly OutOfDateModelsStatus _outOfDateModels;
@@ -29,7 +29,7 @@ namespace Umbraco.ModelsBuilder.Embedded.Compose
private readonly IUmbracoApplicationLifetime _umbracoApplicationLifetime;
private readonly IUmbracoRequestLifetime _umbracoRequestLifetime;
- public ModelsBuilderComponent(IOptions config, IShortStringHelper shortStringHelper,
+ public ModelsBuilderComponent(IOptions config, IShortStringHelper shortStringHelper,
LiveModelsProvider liveModelsProvider, OutOfDateModelsStatus outOfDateModels, LinkGenerator linkGenerator,
IUmbracoRequestLifetime umbracoRequestLifetime, IUmbracoApplicationLifetime umbracoApplicationLifetime)
{
diff --git a/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComposer.cs b/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComposer.cs
index fd5472b223..3e63fb8e94 100644
--- a/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComposer.cs
+++ b/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComposer.cs
@@ -27,7 +27,7 @@ namespace Umbraco.ModelsBuilder.Embedded.Compose
composition.RegisterUnique(factory =>
{
- var config = factory.GetInstance>().Value;
+ var config = factory.GetInstance>().Value;
if (config.ModelsMode == ModelsMode.PureLive)
{
composition.RegisterUnique();
diff --git a/src/Umbraco.ModelsBuilder.Embedded/LiveModelsProvider.cs b/src/Umbraco.ModelsBuilder.Embedded/LiveModelsProvider.cs
index 48a79ba953..628e66bc6a 100644
--- a/src/Umbraco.ModelsBuilder.Embedded/LiveModelsProvider.cs
+++ b/src/Umbraco.ModelsBuilder.Embedded/LiveModelsProvider.cs
@@ -20,7 +20,7 @@ namespace Umbraco.ModelsBuilder.Embedded
private static Mutex _mutex;
private static int _req;
private readonly ILogger _logger;
- private readonly ModelsBuilderConfig _config;
+ private readonly ModelsBuilderSettings _config;
private readonly ModelsGenerator _modelGenerator;
private readonly ModelsGenerationError _mbErrors;
private readonly IHostingEnvironment _hostingEnvironment;
@@ -28,7 +28,7 @@ namespace Umbraco.ModelsBuilder.Embedded
// we do not manage pure live here
internal bool IsEnabled => _config.ModelsMode.IsLiveNotPure();
- public LiveModelsProvider(ILogger logger, IOptions config, ModelsGenerator modelGenerator, ModelsGenerationError mbErrors, IHostingEnvironment hostingEnvironment)
+ public LiveModelsProvider(ILogger logger, IOptions config, ModelsGenerator modelGenerator, ModelsGenerationError mbErrors, IHostingEnvironment hostingEnvironment)
{
_logger = logger;
_config = config.Value ?? throw new ArgumentNullException(nameof(config));
diff --git a/src/Umbraco.ModelsBuilder.Embedded/ModelsGenerationError.cs b/src/Umbraco.ModelsBuilder.Embedded/ModelsGenerationError.cs
index a5911bc9c6..dca2fda0dc 100644
--- a/src/Umbraco.ModelsBuilder.Embedded/ModelsGenerationError.cs
+++ b/src/Umbraco.ModelsBuilder.Embedded/ModelsGenerationError.cs
@@ -10,10 +10,10 @@ namespace Umbraco.ModelsBuilder.Embedded
{
public sealed class ModelsGenerationError
{
- private readonly ModelsBuilderConfig _config;
+ private readonly ModelsBuilderSettings _config;
private readonly IHostingEnvironment _hostingEnvironment;
- public ModelsGenerationError(IOptions config, IHostingEnvironment hostingEnvironment)
+ public ModelsGenerationError(IOptions config, IHostingEnvironment hostingEnvironment)
{
_config = config.Value;
_hostingEnvironment = hostingEnvironment;
diff --git a/src/Umbraco.ModelsBuilder.Embedded/OutOfDateModelsStatus.cs b/src/Umbraco.ModelsBuilder.Embedded/OutOfDateModelsStatus.cs
index 85d08ee975..92e0604a16 100644
--- a/src/Umbraco.ModelsBuilder.Embedded/OutOfDateModelsStatus.cs
+++ b/src/Umbraco.ModelsBuilder.Embedded/OutOfDateModelsStatus.cs
@@ -9,10 +9,10 @@ namespace Umbraco.ModelsBuilder.Embedded
{
public sealed class OutOfDateModelsStatus
{
- private readonly ModelsBuilderConfig _config;
+ private readonly ModelsBuilderSettings _config;
private readonly IHostingEnvironment _hostingEnvironment;
- public OutOfDateModelsStatus(IOptions config, IHostingEnvironment hostingEnvironment)
+ public OutOfDateModelsStatus(IOptions config, IHostingEnvironment hostingEnvironment)
{
_config = config.Value;
_hostingEnvironment = hostingEnvironment;
diff --git a/src/Umbraco.ModelsBuilder.Embedded/PureLiveModelFactory.cs b/src/Umbraco.ModelsBuilder.Embedded/PureLiveModelFactory.cs
index 596cc9ed26..00c5ec723d 100644
--- a/src/Umbraco.ModelsBuilder.Embedded/PureLiveModelFactory.cs
+++ b/src/Umbraco.ModelsBuilder.Embedded/PureLiveModelFactory.cs
@@ -38,7 +38,7 @@ namespace Umbraco.ModelsBuilder.Embedded
private static readonly Regex AssemblyVersionRegex = new Regex("AssemblyVersion\\(\"[0-9]+.[0-9]+.[0-9]+.[0-9]+\"\\)", RegexOptions.Compiled);
private static readonly string[] OurFiles = { "models.hash", "models.generated.cs", "all.generated.cs", "all.dll.path", "models.err", "Compiled" };
- private readonly ModelsBuilderConfig _config;
+ private readonly ModelsBuilderSettings _config;
private readonly IHostingEnvironment _hostingEnvironment;
private readonly IApplicationShutdownRegistry _hostingLifetime;
private readonly ModelsGenerationError _errors;
@@ -47,7 +47,7 @@ namespace Umbraco.ModelsBuilder.Embedded
public PureLiveModelFactory(
Lazy umbracoServices,
IProfilingLogger logger,
- IOptions config,
+ IOptions config,
IHostingEnvironment hostingEnvironment,
IApplicationShutdownRegistry hostingLifetime,
IPublishedValueFallback publishedValueFallback)
diff --git a/src/Umbraco.PublishedCache.NuCache/DataSource/BTree.cs b/src/Umbraco.PublishedCache.NuCache/DataSource/BTree.cs
index ae7393a91a..99d0e9da38 100644
--- a/src/Umbraco.PublishedCache.NuCache/DataSource/BTree.cs
+++ b/src/Umbraco.PublishedCache.NuCache/DataSource/BTree.cs
@@ -45,11 +45,10 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
var blockSize = 4096;
var appSetting = settings.BTreeBlockSize;
- if (appSetting == null)
+ if (!appSetting.HasValue)
return blockSize;
- if (!int.TryParse(appSetting, out blockSize))
- throw new ConfigurationErrorsException($"Invalid block size value \"{appSetting}\": not a number.");
+ blockSize = appSetting.Value;
var bit = 0;
for (var i = blockSize; i != 1; i >>= 1)
diff --git a/src/Umbraco.Tests.Common/Builders/ConnectionStringsBuilder.cs b/src/Umbraco.Tests.Common/Builders/ConnectionStringsBuilder.cs
deleted file mode 100644
index 4aba98fccd..0000000000
--- a/src/Umbraco.Tests.Common/Builders/ConnectionStringsBuilder.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using Umbraco.Core;
-using Umbraco.Core.Configuration;
-using ConnectionStrings = Umbraco.Core.Configuration.Models.ConnectionStrings;
-
-namespace Umbraco.Tests.Common.Builders
-{
- public class ConnectionStringsBuilder : BuilderBase
- {
- private string _umbracoConnectionString;
-
- public ConnectionStringsBuilder WithUmbracoConnectionString(string umbracoConnectionString)
- {
- _umbracoConnectionString = umbracoConnectionString;
- return this;
- }
-
- public override ConnectionStrings Build()
- {
- var umbracoConnectionString = _umbracoConnectionString ?? string.Empty;
-
- return new ConnectionStrings
- {
- UmbracoConnectionString = new ConfigConnectionString(Constants.System.UmbracoConnectionName, umbracoConnectionString),
- };
- }
- }
-}
diff --git a/src/Umbraco.Tests.Common/Builders/ContentSettingsBuilder.cs b/src/Umbraco.Tests.Common/Builders/ContentSettingsBuilder.cs
deleted file mode 100644
index f5fb1fc08f..0000000000
--- a/src/Umbraco.Tests.Common/Builders/ContentSettingsBuilder.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using Umbraco.Core.Configuration.Models;
-
-namespace Umbraco.Tests.Common.Builders
-{
- public class ContentSettingsBuilder : BuilderBase
- {
- public override ContentSettings Build()
- {
- return new ContentSettings();
- }
- }
-}
diff --git a/src/Umbraco.Tests.Common/Builders/CoreDebugSettingsBuilder.cs b/src/Umbraco.Tests.Common/Builders/CoreDebugSettingsBuilder.cs
deleted file mode 100644
index e14fb0ade5..0000000000
--- a/src/Umbraco.Tests.Common/Builders/CoreDebugSettingsBuilder.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using CoreDebugSettings = Umbraco.Core.Configuration.Models.CoreDebugSettings;
-
-namespace Umbraco.Tests.Common.Builders
-{
- public class CoreDebugSettingsBuilder : BuilderBase
- {
- private bool? _dumpOnTimeoutThreadAbort;
- private bool? _logUncompletedScopes;
-
- public CoreDebugSettingsBuilder WithDumpOnTimeoutThreadAbort(bool dumpOnTimeoutThreadAbort)
- {
- _dumpOnTimeoutThreadAbort = dumpOnTimeoutThreadAbort;
- return this;
- }
-
- public CoreDebugSettingsBuilder WithLogUncompletedScopes(bool logUncompletedScopes)
- {
- _logUncompletedScopes = logUncompletedScopes;
- return this;
- }
-
- public override CoreDebugSettings Build()
- {
- var dumpOnTimeoutThreadAbort = _dumpOnTimeoutThreadAbort ?? false;
- var logUncompletedScopes = _logUncompletedScopes ?? false;
-
- return new CoreDebugSettings
- {
- DumpOnTimeoutThreadAbort = dumpOnTimeoutThreadAbort,
- LogUncompletedScopes = logUncompletedScopes,
- };
- }
- }
-}
diff --git a/src/Umbraco.Tests.Common/Builders/GlobalSettingsBuilder.cs b/src/Umbraco.Tests.Common/Builders/GlobalSettingsBuilder.cs
deleted file mode 100644
index d39bd71d2e..0000000000
--- a/src/Umbraco.Tests.Common/Builders/GlobalSettingsBuilder.cs
+++ /dev/null
@@ -1,207 +0,0 @@
-using Umbraco.Core.Configuration.Models;
-
-namespace Umbraco.Tests.Common.Builders
-{
- public class GlobalSettingsBuilder : GlobalSettingsBuilder