Implemented config for asp.net core
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Umbraco.Configuration.Models;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.HealthChecks;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using CoreDebugSettings = Umbraco.Configuration.Models.CoreDebugSettings;
|
||||
|
||||
namespace Umbraco.Configuration
|
||||
{
|
||||
public class AspNetCoreConfigsFactory : IConfigsFactory
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public AspNetCoreConfigsFactory(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public Configs Create()
|
||||
{
|
||||
var configs = new Configs();
|
||||
|
||||
configs.Add<ITourSettings>(() => new TourSettings(_configuration));
|
||||
configs.Add<ICoreDebugSettings>(() => new CoreDebugSettings(_configuration));
|
||||
configs.Add<IRequestHandlerSettings>(() => new RequestHandlerSettings(_configuration));
|
||||
configs.Add<ISecuritySettings>(() => new SecuritySettings(_configuration));
|
||||
configs.Add<IUserPasswordConfiguration>(() => new UserPasswordConfigurationSettings(_configuration));
|
||||
configs.Add<IMemberPasswordConfiguration>(() => new MemberPasswordConfigurationSettings(_configuration));
|
||||
configs.Add<IKeepAliveSettings>(() => new KeepAliveSettings(_configuration));
|
||||
configs.Add<IContentSettings>(() => new ContentSettings(_configuration));
|
||||
configs.Add<IHealthChecksSettings>(() => new HealthChecksSettingsSettings(_configuration));
|
||||
configs.Add<ILoggingSettings>(() => new LoggingSettings(_configuration));
|
||||
configs.Add<IExceptionFilterSettings>(() => new ExceptionFilterSettings(_configuration));
|
||||
configs.Add<IActiveDirectorySettings>(() => new ActiveDirectorySettings(_configuration));
|
||||
configs.Add<IRuntimeSettings>(() => new RuntimeSettings(_configuration));
|
||||
configs.Add<ITypeFinderSettings>(() => new TypeFinderSettings(_configuration));
|
||||
configs.Add<INuCacheSettings>(() => new NuCacheSettings(_configuration));
|
||||
configs.Add<IWebRoutingSettings>(() => new WebRoutingSettings(_configuration));
|
||||
configs.Add<IIndexCreatorSettings>(() => new IndexCreatorSettings(_configuration));
|
||||
configs.Add<IModelsBuilderConfig>(() => new ModelsBuilderConfig(_configuration));
|
||||
|
||||
// configs.Add<IGlobalSettings>(() => GlobalSettings);
|
||||
// configs.Add<IConnectionStrings>(() => ConnectionStrings);
|
||||
// configs.Add<IHostingSettings>(() => HostingSettings);
|
||||
// configs.Add<IMachineKeyConfig>(() => MachineKeyConfig);
|
||||
|
||||
|
||||
|
||||
|
||||
return configs;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using Umbraco.Configuration;
|
||||
using Umbraco.Configuration.Implementations;
|
||||
using Umbraco.Configuration.Legacy;
|
||||
using Umbraco.Core.Configuration.HealthChecks;
|
||||
using Umbraco.Core.Configuration.Implementations;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
@@ -9,7 +10,7 @@ namespace Umbraco.Core.Configuration
|
||||
public class ConfigsFactory : IConfigsFactory
|
||||
{
|
||||
public IHostingSettings HostingSettings { get; } = new HostingSettings();
|
||||
public ICoreDebug CoreDebug { get; } = new CoreDebug();
|
||||
public ICoreDebugSettings CoreDebugSettings { get; } = new CoreDebugSettings();
|
||||
public IMachineKeyConfig MachineKeyConfig { get; } = new MachineKeyConfig();
|
||||
public IIndexCreatorSettings IndexCreatorSettings { get; } = new IndexCreatorSettings();
|
||||
public INuCacheSettings NuCacheSettings { get; } = new NuCacheSettings();
|
||||
@@ -27,7 +28,7 @@ namespace Umbraco.Core.Configuration
|
||||
public IMemberPasswordConfiguration MemberPasswordConfigurationSettings { get; } = new MemberPasswordConfigurationSettings();
|
||||
public IContentSettings ContentSettings { get; } = new ContentSettings();
|
||||
public IGlobalSettings GlobalSettings { get; } = new GlobalSettings();
|
||||
public IHealthChecks HealthChecksSettings { get; } = new HealthChecksSettings();
|
||||
public IHealthChecksSettings HealthChecksSettingsSettings { get; } = new HealthChecksSettingsSettings();
|
||||
public IConnectionStrings ConnectionStrings { get; } = new ConnectionStrings();
|
||||
public IModelsBuilderConfig ModelsBuilderConfig { get; } = new ModelsBuilderConfig();
|
||||
|
||||
@@ -37,8 +38,8 @@ namespace Umbraco.Core.Configuration
|
||||
|
||||
configs.Add<IGlobalSettings>(() => GlobalSettings);
|
||||
configs.Add<IHostingSettings>(() => HostingSettings);
|
||||
configs.Add<IHealthChecks>(() => HealthChecksSettings);
|
||||
configs.Add<ICoreDebug>(() => CoreDebug);
|
||||
configs.Add<IHealthChecksSettings>(() => HealthChecksSettingsSettings);
|
||||
configs.Add<ICoreDebugSettings>(() => CoreDebugSettings);
|
||||
configs.Add<IMachineKeyConfig>(() => MachineKeyConfig);
|
||||
configs.Add<IConnectionStrings>(() => ConnectionStrings);
|
||||
configs.Add<IModelsBuilderConfig>(() => ModelsBuilderConfig);
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
using System.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Configuration
|
||||
namespace Umbraco.Configuration.Legacy
|
||||
{
|
||||
public class ActiveDirectorySettings : IActiveDirectorySettings
|
||||
{
|
||||
+2
-2
@@ -3,9 +3,9 @@ using System.Configuration;
|
||||
|
||||
namespace Umbraco.Core.Configuration
|
||||
{
|
||||
public class CoreDebug : ICoreDebug
|
||||
public class CoreDebugSettings : ICoreDebugSettings
|
||||
{
|
||||
public CoreDebug()
|
||||
public CoreDebugSettings()
|
||||
{
|
||||
var appSettings = ConfigurationManager.AppSettings;
|
||||
LogUncompletedScopes = string.Equals("true", appSettings[Constants.AppSettings.Debug.LogUncompletedScopes], StringComparison.OrdinalIgnoreCase);
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
using System.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Configuration
|
||||
namespace Umbraco.Configuration.Legacy
|
||||
{
|
||||
public class ExceptionFilterSettings : IExceptionFilterSettings
|
||||
{
|
||||
+1
-1
@@ -4,7 +4,7 @@ using Umbraco.Core.Configuration.HealthChecks;
|
||||
|
||||
namespace Umbraco.Core.Configuration.Implementations
|
||||
{
|
||||
public class HealthChecksSettings : IHealthChecks
|
||||
public class HealthChecksSettingsSettings : IHealthChecksSettings
|
||||
{
|
||||
private HealthChecksSection _healthChecksSection;
|
||||
|
||||
+2
-2
@@ -1,13 +1,13 @@
|
||||
using System.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Configuration
|
||||
namespace Umbraco.Configuration.Legacy
|
||||
{
|
||||
public class IndexCreatorSettings : IIndexCreatorSettings
|
||||
{
|
||||
public IndexCreatorSettings()
|
||||
{
|
||||
LuceneDirectoryFactory = ConfigurationManager.AppSettings["Umbraco.Examine.LuceneDirectoryFactory"];
|
||||
LuceneDirectoryFactory = ConfigurationManager.AppSettings["Umbraco.Examine.LuceneDirectoryFactory"];
|
||||
}
|
||||
|
||||
public string LuceneDirectoryFactory { get; }
|
||||
+1
-1
@@ -6,7 +6,7 @@ using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.IO;
|
||||
|
||||
namespace Umbraco.Configuration
|
||||
namespace Umbraco.Configuration.Legacy
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the models builder configuration.
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
using System.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Configuration
|
||||
namespace Umbraco.Configuration.Legacy
|
||||
{
|
||||
public class NuCacheSettings : INuCacheSettings
|
||||
{
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
using System.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Configuration
|
||||
namespace Umbraco.Configuration.Legacy
|
||||
{
|
||||
public class RuntimeSettings : IRuntimeSettings
|
||||
{
|
||||
@@ -24,6 +24,6 @@ namespace Umbraco.Configuration
|
||||
}
|
||||
public int? MaxQueryStringLength { get; }
|
||||
public int? MaxRequestLength { get; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
using System.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Configuration
|
||||
namespace Umbraco.Configuration.Legacy
|
||||
{
|
||||
public class TypeFinderSettings : ITypeFinderSettings
|
||||
{
|
||||
@@ -0,0 +1,17 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Configuration.Models
|
||||
{
|
||||
internal class ActiveDirectorySettings : IActiveDirectorySettings
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public ActiveDirectorySettings(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public string ActiveDirectoryDomain => _configuration.GetValue<string>("Umbraco:CMS:ActiveDirectory:Domain");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Macros;
|
||||
|
||||
|
||||
namespace Umbraco.Configuration.Models
|
||||
{
|
||||
internal class ContentSettings : IContentSettings
|
||||
{
|
||||
|
||||
private readonly IConfiguration _configuration;
|
||||
public ContentSettings(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
private const string DefaultPreviewBadge = @"<div id=""umbracoPreviewBadge"" class=""umbraco-preview-badge""><span class=""umbraco-preview-badge__header"">Preview mode</span><a href=""{0}/preview/end?redir={1}"" class=""umbraco-preview-badge__end""><svg viewBox=""0 0 100 100"" xmlns=""http://www.w3.org/2000/svg""><title>Click to end</title><path d=""M5273.1 2400.1v-2c0-2.8-5-4-9.7-4s-9.7 1.3-9.7 4v2a7 7 0 002 4.9l5 4.9c.3.3.4.6.4 1v6.4c0 .4.2.7.6.8l2.9.9c.5.1 1-.2 1-.8v-7.2c0-.4.2-.7.4-1l5.1-5a7 7 0 002-4.9zm-9.7-.1c-4.8 0-7.4-1.3-7.5-1.8.1-.5 2.7-1.8 7.5-1.8s7.3 1.3 7.5 1.8c-.2.5-2.7 1.8-7.5 1.8z""/><path d=""M5268.4 2410.3c-.6 0-1 .4-1 1s.4 1 1 1h4.3c.6 0 1-.4 1-1s-.4-1-1-1h-4.3zM5272.7 2413.7h-4.3c-.6 0-1 .4-1 1s.4 1 1 1h4.3c.6 0 1-.4 1-1s-.4-1-1-1zM5272.7 2417h-4.3c-.6 0-1 .4-1 1s.4 1 1 1h4.3c.6 0 1-.4 1-1 0-.5-.4-1-1-1z""/><path d=""M78.2 13l-8.7 11.7a32.5 32.5 0 11-51.9 25.8c0-10.3 4.7-19.7 12.9-25.8L21.8 13a47 47 0 1056.4 0z""/><path d=""M42.7 2.5h14.6v49.4H42.7z""/></svg></a></div><style type=""text/css"">.umbraco-preview-badge {{position: absolute;top: 1em;right: 1em;display: inline-flex;background: #1b264f;color: #fff;padding: 1em;font-size: 12px;z-index: 99999999;justify-content: center;align-items: center;box-shadow: 0 10px 50px rgba(0, 0, 0, .1), 0 6px 20px rgba(0, 0, 0, .16);line-height: 1;}}.umbraco-preview-badge__header {{font-weight: bold;}}.umbraco-preview-badge__end {{width: 3em;padding: 1em;margin: -1em -1em -1em 2em;display: flex;flex-shrink: 0;align-items: center;align-self: stretch;}}.umbraco-preview-badge__end:hover,.umbraco-preview-badge__end:focus {{background: #f5c1bc;}}.umbraco-preview-badge__end svg {{fill: #fff;width:1em;}}</style>";
|
||||
|
||||
private static IEnumerable<IImagingAutoFillUploadField> DefaultImagingAutoFillUploadField = new[]
|
||||
{
|
||||
new ImagingAutoFillUploadField()
|
||||
{
|
||||
Alias = "umbracoFile"
|
||||
},
|
||||
};
|
||||
|
||||
public string NotificationEmailAddress => _configuration.GetValue<string>("Umbraco:CMS:Content:Notifications:Email") ?? null;
|
||||
public bool DisableHtmlEmail => _configuration.GetValue<bool?>("Umbraco:CMS:Content:Notifications:DisableHtmlEmail") ?? false;
|
||||
public IEnumerable<string> ImageFileTypes => _configuration.GetValue<string[]>("Umbraco:CMS:Content:Imaging:ImageFileTypes") ?? new[] {"jpeg", "jpg", "gif", "bmp", "png", "tiff", "tif"};
|
||||
public IEnumerable<IImagingAutoFillUploadField> ImageAutoFillProperties => _configuration.GetValue<ImagingAutoFillUploadField[]>("Umbraco:CMS:Core:Content:Imaging:autoFillImageProperties") ?? DefaultImagingAutoFillUploadField;
|
||||
|
||||
|
||||
public bool ResolveUrlsFromTextString => _configuration.GetValue<bool?>("Umbraco:CMS:Content:ResolveUrlsFromTextString") ?? false;
|
||||
public IEnumerable<IContentErrorPage> Error404Collection => _configuration
|
||||
.GetSection("Umbraco:CMS:Content:Errors:Error404")
|
||||
.GetChildren()
|
||||
.Select(x=> new ContentErrorPage(x));
|
||||
public string PreviewBadge => _configuration.GetValue<string>("Umbraco:CMS:Content:PreviewBadge") ?? DefaultPreviewBadge;
|
||||
public MacroErrorBehaviour MacroErrorBehaviour => _configuration.GetValue<MacroErrorBehaviour?>("Umbraco:CMS:Content:MacroErrors") ?? MacroErrorBehaviour.Inline;
|
||||
public IEnumerable<string> DisallowedUploadFiles => _configuration.GetValue<string[]>("Umbraco:CMS:Content:DisallowedUploadFiles") ?? new[] {"ashx", "aspx", "ascx", "config", "cshtml", "vbhtml", "asmx", "air", "axd"};
|
||||
public IEnumerable<string> AllowedUploadFiles => _configuration.GetValue<string[]>("Umbraco:CMS:Content:AllowedUploadFiles") ?? Array.Empty<string>() ;
|
||||
public bool ShowDeprecatedPropertyEditors => _configuration.GetValue<bool?>("Umbraco:CMS:Content:ShowDeprecatedPropertyEditors") ?? false;
|
||||
public string LoginBackgroundImage => _configuration.GetValue<string>("Umbraco:CMS:Content:LoginBackgroundImage") ?? string.Empty;
|
||||
|
||||
private class ContentErrorPage : IContentErrorPage
|
||||
{
|
||||
public ContentErrorPage(IConfigurationSection configurationSection)
|
||||
{
|
||||
Culture = configurationSection.Key;
|
||||
|
||||
var value = configurationSection.Value;
|
||||
|
||||
if(int.TryParse(value, out var contentId))
|
||||
{
|
||||
HasContentId = true;
|
||||
ContentId = contentId;
|
||||
}
|
||||
else if(Guid.TryParse(value, out var contentKey))
|
||||
{
|
||||
HasContentKey = true;
|
||||
ContentKey = contentKey;
|
||||
}
|
||||
else
|
||||
{
|
||||
ContentXPath = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int ContentId { get; set; }
|
||||
public Guid ContentKey { get; set;}
|
||||
public string ContentXPath { get; set;}
|
||||
public bool HasContentId { get; set;}
|
||||
public bool HasContentKey { get; set;}
|
||||
public string Culture { get; set; }
|
||||
}
|
||||
|
||||
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; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Configuration.Models
|
||||
{
|
||||
internal class CoreDebugSettings : ICoreDebugSettings
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
public CoreDebugSettings(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
public bool LogUncompletedScopes => _configuration.GetValue<bool?>("Umbraco:CMS:Core:Debug:LogUncompletedScopes") ?? false;
|
||||
public bool DumpOnTimeoutThreadAbort => _configuration.GetValue<bool?>("Umbraco:CMS:Core:Debug:DumpOnTimeoutThreadAbort") ?? false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Configuration.Models
|
||||
{
|
||||
internal class ExceptionFilterSettings : IExceptionFilterSettings
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public ExceptionFilterSettings(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public bool Disabled => _configuration.GetValue("Umbraco:CMS:ExceptionFilter:Disabled", false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Umbraco.Core.Configuration.HealthChecks;
|
||||
|
||||
namespace Umbraco.Configuration.Models
|
||||
{
|
||||
internal class HealthChecksSettingsSettings : IHealthChecksSettings
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
public HealthChecksSettingsSettings(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public IEnumerable<IDisabledHealthCheck> DisabledChecks => _configuration.GetSection("Umbraco:CMS:HealthChecks:DisabledChecks").GetChildren().Select(
|
||||
x => new DisabledHealthCheck()
|
||||
{
|
||||
Id = x.GetValue<Guid>("Id"),
|
||||
DisabledOn = x.GetValue<DateTime>("DisabledOn"),
|
||||
DisabledBy = x.GetValue<int>("DisabledBy"),
|
||||
});
|
||||
public IHealthCheckNotificationSettings NotificationSettings => new HealthCheckNotificationSettings(_configuration.GetSection("Umbraco:CMS:HealthChecks:NotificationSettings"));
|
||||
|
||||
private class DisabledHealthCheck : IDisabledHealthCheck
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public DateTime DisabledOn { get;set; }
|
||||
public int DisabledBy { get;set; }
|
||||
}
|
||||
|
||||
private class HealthCheckNotificationSettings : IHealthCheckNotificationSettings
|
||||
{
|
||||
private readonly IConfigurationSection _configurationSection;
|
||||
|
||||
public HealthCheckNotificationSettings(IConfigurationSection configurationSection)
|
||||
{
|
||||
_configurationSection = configurationSection;
|
||||
}
|
||||
|
||||
public bool Enabled => _configurationSection.GetValue<bool>("Enabled", false);
|
||||
public string FirstRunTime => _configurationSection.GetValue<string>("FirstRunTime");
|
||||
public int PeriodInHours => _configurationSection.GetValue<int>("PeriodInHours", 24);
|
||||
|
||||
public IReadOnlyDictionary<string, INotificationMethod> NotificationMethods => _configurationSection
|
||||
.GetSection("NotificationMethods")
|
||||
.GetChildren()
|
||||
.ToDictionary(x=>x.Key, x=> (INotificationMethod) new NotificationMethod(x.Key, x));
|
||||
|
||||
public IEnumerable<IDisabledHealthCheck> DisabledChecks =>
|
||||
_configurationSection.GetValue<DisabledHealthCheck[]>("DisabledChecks", Array.Empty<DisabledHealthCheck>());
|
||||
}
|
||||
|
||||
private class NotificationMethod : INotificationMethod
|
||||
{
|
||||
private readonly IConfigurationSection _configurationSection;
|
||||
|
||||
public NotificationMethod(string alias, IConfigurationSection configurationSection)
|
||||
{
|
||||
Alias = alias;
|
||||
_configurationSection = configurationSection;
|
||||
}
|
||||
|
||||
public string Alias { get; }
|
||||
public bool Enabled => _configurationSection.GetValue<bool>("Enabled", false);
|
||||
public HealthCheckNotificationVerbosity Verbosity => _configurationSection.GetValue<HealthCheckNotificationVerbosity>("Verbosity", HealthCheckNotificationVerbosity.Summary);
|
||||
public bool FailureOnly => _configurationSection.GetValue<bool>("FailureOnly", true);
|
||||
|
||||
public IReadOnlyDictionary<string, INotificationMethodSettings> Settings => _configurationSection
|
||||
.GetSection("Settings").GetChildren().ToDictionary(x => x.Key, x => (INotificationMethodSettings)new NotificationMethodSettings(x.Key, x.Value));
|
||||
}
|
||||
|
||||
private class NotificationMethodSettings : INotificationMethodSettings
|
||||
{
|
||||
public NotificationMethodSettings(string key, string value)
|
||||
{
|
||||
Key = key;
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public string Key { get; }
|
||||
public string Value { get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Configuration.Models
|
||||
{
|
||||
internal class IndexCreatorSettings : IIndexCreatorSettings
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public IndexCreatorSettings(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public string LuceneDirectoryFactory =>
|
||||
_configuration.GetValue<string>("Umbraco:CMS:Examine:LuceneDirectoryFactory");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
|
||||
namespace Umbraco.Configuration.Models
|
||||
{
|
||||
internal class KeepAliveSettings : IKeepAliveSettings
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
public KeepAliveSettings(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
public bool DisableKeepAliveTask => _configuration.GetValue<bool?>("Umbraco:CMS:KeepAlive:DisableKeepAliveTask") ?? false;
|
||||
public string KeepAlivePingUrl => _configuration.GetValue<string>("Umbraco:CMS:KeepAlive:KeepAlivePingUrl") ?? "{umbracoApplicationUrl}/api/keepalive/ping";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
|
||||
namespace Umbraco.Configuration.Models
|
||||
{
|
||||
internal class LoggingSettings : ILoggingSettings
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
public LoggingSettings(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
public int MaxLogAge => _configuration.GetValue<int?>("Umbraco:CMS:Logging:MaxLogAge") ?? -1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Configuration.Models
|
||||
{
|
||||
internal class MemberPasswordConfigurationSettings : IMemberPasswordConfiguration
|
||||
{
|
||||
|
||||
private readonly IConfiguration _configuration;
|
||||
public MemberPasswordConfigurationSettings(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public int RequiredLength => _configuration.GetValue<int?>("Umbraco:CMS:Security:MemberPassword:RequiredLength") ?? 10;
|
||||
public bool RequireNonLetterOrDigit => _configuration.GetValue<bool?>("Umbraco:CMS:Security:MemberPassword:RequireNonLetterOrDigit") ?? false;
|
||||
public bool RequireDigit => _configuration.GetValue<bool?>("Umbraco:CMS:Security:MemberPassword:RequireDigit") ?? false;
|
||||
public bool RequireLowercase => _configuration.GetValue<bool?>("Umbraco:CMS:Security:MemberPassword:RequireLowercase") ?? false;
|
||||
public bool RequireUppercase => _configuration.GetValue<bool?>("Umbraco:CMS:Security:MemberPassword:RequireUppercase") ?? false;
|
||||
public bool UseLegacyEncoding => _configuration.GetValue<bool?>("Umbraco:CMS:Security:MemberPassword:UseLegacyEncoding") ?? false;
|
||||
public string HashAlgorithmType => _configuration.GetValue<string>("Umbraco:CMS:Security:MemberPassword:HashAlgorithmType") ?? "HMACSHA256";
|
||||
public int MaxFailedAccessAttemptsBeforeLockout => _configuration.GetValue<int?>("Umbraco:CMS:Security:MemberPassword:MaxFailedAccessAttemptsBeforeLockout") ?? 5;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.IO;
|
||||
using ConfigurationSection = System.Configuration.ConfigurationSection;
|
||||
|
||||
namespace Umbraco.Configuration.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the models builder configuration.
|
||||
/// </summary>
|
||||
internal class ModelsBuilderConfig : IModelsBuilderConfig
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
public string DefaultModelsDirectory => "~/App_Data/Models";
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ModelsBuilderConfig"/> class.
|
||||
/// </summary>
|
||||
public ModelsBuilderConfig(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
private static string GetModelsDirectory(string root, string config, bool acceptUnsafe)
|
||||
{
|
||||
// making sure it is safe, ie under the website root,
|
||||
// unless AcceptUnsafeModelsDirectory and then everything is OK.
|
||||
|
||||
if (!Path.IsPathRooted(root))
|
||||
throw new ConfigurationErrorsException($"Root is not rooted \"{root}\".");
|
||||
|
||||
if (config.StartsWith("~/"))
|
||||
{
|
||||
var dir = Path.Combine(root, config.TrimStart("~/"));
|
||||
|
||||
// sanitize - GetFullPath will take care of any relative
|
||||
// segments in path, eg '../../foo.tmp' - it may throw a SecurityException
|
||||
// if the combined path reaches illegal parts of the filesystem
|
||||
dir = Path.GetFullPath(dir);
|
||||
root = Path.GetFullPath(root);
|
||||
|
||||
if (!dir.StartsWith(root) && !acceptUnsafe)
|
||||
throw new ConfigurationErrorsException($"Invalid models directory \"{config}\".");
|
||||
|
||||
return dir;
|
||||
}
|
||||
|
||||
if (acceptUnsafe)
|
||||
return Path.GetFullPath(config);
|
||||
|
||||
throw new ConfigurationErrorsException($"Invalid models directory \"{config}\".");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the whole models experience is enabled.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>If this is false then absolutely nothing happens.</para>
|
||||
/// <para>Default value is <c>false</c> which means that unless we have this setting, nothing happens.</para>
|
||||
/// </remarks>
|
||||
public bool Enable => _configuration.GetValue("Umbraco:CMS:ModelsBuilder:Enable", false);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the models mode.
|
||||
/// </summary>
|
||||
public ModelsMode ModelsMode => _configuration.GetValue("Umbraco:CMS:ModelsBuilder:ModelsMode", ModelsMode.Nothing);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the models namespace.
|
||||
/// </summary>
|
||||
/// <remarks>That value could be overriden by other (attribute in user's code...). Return default if no value was supplied.</remarks>
|
||||
public string ModelsNamespace => _configuration.GetValue<string>("Umbraco:CMS:ModelsBuilder:ModelsNamespace");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether we should enable the models factory.
|
||||
/// </summary>
|
||||
/// <remarks>Default value is <c>true</c> because no factory is enabled by default in Umbraco.</remarks>
|
||||
public bool EnableFactory => _configuration.GetValue("Umbraco:CMS:ModelsBuilder:EnableFactory", true);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether we should flag out-of-date models.
|
||||
/// </summary>
|
||||
/// <remarks>Models become out-of-date when data types or content types are updated. When this
|
||||
/// setting is activated the ~/App_Data/Models/ood.txt file is then created. When models are
|
||||
/// generated through the dashboard, the files is cleared. Default value is <c>false</c>.</remarks>
|
||||
public bool FlagOutOfDateModels => _configuration.GetValue("Umbraco:CMS:ModelsBuilder:FlagOutOfDateModels", false) && !ModelsMode.IsLive();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the models directory.
|
||||
/// </summary>
|
||||
/// <remarks>Default is ~/App_Data/Models but that can be changed.</remarks>
|
||||
public string ModelsDirectory => GetModelsDirectory("~/",_configuration.GetValue("Umbraco:CMS:ModelsBuilder:ModelsDirectory", "~/App_Data/Models"), AcceptUnsafeModelsDirectory);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether to accept an unsafe value for ModelsDirectory.
|
||||
/// </summary>
|
||||
/// <remarks>An unsafe value is an absolute path, or a relative path pointing outside
|
||||
/// of the website root.</remarks>
|
||||
public bool AcceptUnsafeModelsDirectory => _configuration.GetValue("Umbraco:CMS:ModelsBuilder:AcceptUnsafeModelsDirectory", false);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating the debug log level.
|
||||
/// </summary>
|
||||
/// <remarks>0 means minimal (safe on live site), anything else means more and more details (maybe not safe).</remarks>
|
||||
public int DebugLevel => _configuration.GetValue("Umbraco:CMS:ModelsBuilder:DebugLevel", 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Configuration.Models
|
||||
{
|
||||
internal class NuCacheSettings : INuCacheSettings
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public NuCacheSettings(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public string BTreeBlockSize => _configuration.GetValue<string>("Umbraco:CMS:NuCache:BTreeBlockSize");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
|
||||
namespace Umbraco.Configuration.Models
|
||||
{
|
||||
internal class RequestHandlerSettings : IRequestHandlerSettings
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
public RequestHandlerSettings(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public bool AddTrailingSlash => _configuration.GetValue<bool?>("Umbraco:CMS:RequestHandler:AddTrailingSlash") ?? true;
|
||||
public bool ConvertUrlsToAscii => _configuration.GetValue<string>("Umbraco:CMS:RequestHandler:ConvertUrlsToAscii").InvariantEquals("true");
|
||||
public bool TryConvertUrlsToAscii => _configuration.GetValue<string>("Umbraco:CMS:RequestHandler:ConvertUrlsToAscii").InvariantEquals("try");
|
||||
|
||||
|
||||
//We need to special handle ":", as this character is special in keys
|
||||
public IEnumerable<IChar> CharCollection => _configuration.GetSection("Umbraco:CMS:RequestHandler:CharCollection")
|
||||
.GetChildren()
|
||||
.Select(kvp => new CharItem()
|
||||
{
|
||||
Char = kvp.Key,
|
||||
Replacement = kvp.Value
|
||||
}).Union(new []
|
||||
{
|
||||
new CharItem(){Char = ":", Replacement = string.Empty},
|
||||
});
|
||||
|
||||
private class CharItem : IChar
|
||||
{
|
||||
|
||||
public string Char { get; set; }
|
||||
public string Replacement { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Configuration.Models
|
||||
{
|
||||
internal class RuntimeSettings : IRuntimeSettings
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
public RuntimeSettings(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public int? MaxQueryStringLength => _configuration.GetValue<int?>("Umbraco:CMS:Runtime:MaxRequestLength");
|
||||
public int? MaxRequestLength => _configuration.GetValue<int?>("Umbraco:CMS:Runtime:MaxRequestLength");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
|
||||
namespace Umbraco.Configuration.Models
|
||||
{
|
||||
internal class SecuritySettings : ISecuritySettings
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
public SecuritySettings(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
public bool KeepUserLoggedIn => _configuration.GetValue<bool?>("Umbraco:CMS:Security:KeepUserLoggedIn") ?? true;
|
||||
public bool HideDisabledUsersInBackoffice => _configuration.GetValue<bool?>("Umbraco:CMS:Security:HideDisabledUsersInBackoffice") ?? false;
|
||||
public bool AllowPasswordReset => _configuration.GetValue<bool?>("Umbraco:CMS:Security:AllowPasswordResetAllowPasswordReset") ?? true;
|
||||
public string AuthCookieName => _configuration.GetValue<string>("Umbraco:CMS:Security:AuthCookieName") ?? "UMB_UCONTEXT";
|
||||
public string AuthCookieDomain => _configuration.GetValue<string>("Umbraco:CMS:Security:AuthCookieDomain") ?? null;
|
||||
public bool UsernameIsEmail => _configuration.GetValue<bool?>("Umbraco:CMS:Security:UsernameIsEmail") ?? true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
|
||||
namespace Umbraco.Configuration.Models
|
||||
{
|
||||
internal class TourSettings : ITourSettings
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
public TourSettings(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public bool EnableTours => _configuration.GetValue<bool?>("Umbraco:CMS:Tours:EnableTours") ?? true;
|
||||
|
||||
public string Type { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Configuration.Models
|
||||
{
|
||||
internal class TypeFinderSettings : ITypeFinderSettings
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public TypeFinderSettings(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public string AssembliesAcceptingLoadExceptions =>
|
||||
_configuration.GetValue<string>("Umbraco:CMS:TypeFinder:AssembliesAcceptingLoadExceptions");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Configuration.Models
|
||||
{
|
||||
internal class UserPasswordConfigurationSettings : IUserPasswordConfiguration
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
public UserPasswordConfigurationSettings(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public int RequiredLength => _configuration.GetValue<int?>("Umbraco:CMS:Security:UserPassword:RequiredLength") ?? 10;
|
||||
public bool RequireNonLetterOrDigit => _configuration.GetValue<bool?>("Umbraco:CMS:Security:UserPassword:RequireNonLetterOrDigit") ?? false;
|
||||
public bool RequireDigit => _configuration.GetValue<bool?>("Umbraco:CMS:Security:UserPassword:RequireDigit") ?? false;
|
||||
public bool RequireLowercase => _configuration.GetValue<bool?>("Umbraco:CMS:Security:UserPassword:RequireLowercase") ?? false;
|
||||
public bool RequireUppercase => _configuration.GetValue<bool?>("Umbraco:CMS:Security:UserPassword:RequireUppercase") ?? false;
|
||||
public bool UseLegacyEncoding => _configuration.GetValue<bool?>("Umbraco:CMS:Security:UserPassword:UseLegacyEncoding") ?? false;
|
||||
public string HashAlgorithmType => _configuration.GetValue<string>("Umbraco:CMS:Security:UserPassword:HashAlgorithmType") ?? "HMACSHA256";
|
||||
public int MaxFailedAccessAttemptsBeforeLockout => _configuration.GetValue<int?>("Umbraco:CMS:Security:UserPassword:MaxFailedAccessAttemptsBeforeLockout") ?? 5;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
|
||||
namespace Umbraco.Configuration.Models
|
||||
{
|
||||
internal class WebRoutingSettings : IWebRoutingSettings
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
public WebRoutingSettings(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public bool TrySkipIisCustomErrors => _configuration.GetValue<bool?>("Umbraco:CMS:WebRouting:TrySkipIisCustomErrors") ?? false;
|
||||
public bool InternalRedirectPreservesTemplate => _configuration.GetValue<bool?>("Umbraco:CMS:WebRouting:InternalRedirectPreservesTemplate") ?? false;
|
||||
public bool DisableAlternativeTemplates => _configuration.GetValue<bool?>("Umbraco:CMS:WebRouting:DisableAlternativeTemplates") ?? false;
|
||||
public bool ValidateAlternativeTemplates => _configuration.GetValue<bool?>("Umbraco:CMS:WebRouting:ValidateAlternativeTemplates") ?? false;
|
||||
public bool DisableFindContentByIdPath => _configuration.GetValue<bool?>("Umbraco:CMS:WebRouting:DisableFindContentByIdPath") ?? false;
|
||||
public bool DisableRedirectUrlTracking => _configuration.GetValue<bool?>("Umbraco:CMS:WebRouting:DisableRedirectUrlTracking") ?? false;
|
||||
public string UrlProviderMode => _configuration.GetValue<string?>("Umbraco:CMS:WebRouting:UrlProviderMode") ?? UrlMode.Auto.ToString();
|
||||
public string UmbracoApplicationUrl => _configuration.GetValue<string?>("Umbraco:CMS:WebRouting:UmbracoApplicationUrl") ?? null;
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,8 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="3.1.2" />
|
||||
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.6.0" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -29,4 +31,8 @@
|
||||
<ProjectReference Include="..\Umbraco.Core\Umbraco.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Implementations" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -37,10 +37,10 @@ namespace Umbraco.Core
|
||||
public static IWebRoutingSettings WebRouting(this Configs configs)
|
||||
=> configs.GetConfig<IWebRoutingSettings>();
|
||||
|
||||
public static IHealthChecks HealthChecks(this Configs configs)
|
||||
=> configs.GetConfig<IHealthChecks>();
|
||||
public static ICoreDebug CoreDebug(this Configs configs)
|
||||
=> configs.GetConfig<ICoreDebug>();
|
||||
public static IHealthChecksSettings HealthChecks(this Configs configs)
|
||||
=> configs.GetConfig<IHealthChecksSettings>();
|
||||
public static ICoreDebugSettings CoreDebug(this Configs configs)
|
||||
=> configs.GetConfig<ICoreDebugSettings>();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Umbraco.Core.Configuration.HealthChecks
|
||||
{
|
||||
public interface IHealthChecks
|
||||
public interface IHealthChecksSettings
|
||||
{
|
||||
IEnumerable<IDisabledHealthCheck> DisabledChecks { get; }
|
||||
IHealthCheckNotificationSettings NotificationSettings { get; }
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
namespace Umbraco.Core.Configuration
|
||||
{
|
||||
public interface ICoreDebug
|
||||
public interface ICoreDebugSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// When set to true, Scope logs the stack trace for any scope that gets disposed without being completed.
|
||||
@@ -7,7 +7,6 @@
|
||||
int DebugLevel { get; }
|
||||
bool EnableFactory { get; }
|
||||
bool FlagOutOfDateModels { get; }
|
||||
bool IsDebug { get; }
|
||||
string ModelsDirectory { get; }
|
||||
ModelsMode ModelsMode { get; }
|
||||
string ModelsNamespace { get; }
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods
|
||||
private readonly IGlobalSettings _globalSettings;
|
||||
private readonly IContentSettings _contentSettings;
|
||||
|
||||
public EmailNotificationMethod(ILocalizedTextService textService, IRuntimeState runtimeState, ILogger logger, IGlobalSettings globalSettings, IHealthChecks healthChecks, IContentSettings contentSettings) : base(healthChecks)
|
||||
public EmailNotificationMethod(ILocalizedTextService textService, IRuntimeState runtimeState, ILogger logger, IGlobalSettings globalSettings, IHealthChecksSettings healthChecksSettings, IContentSettings contentSettings) : base(healthChecksSettings)
|
||||
{
|
||||
var recipientEmail = Settings["recipientEmail"]?.Value;
|
||||
if (string.IsNullOrWhiteSpace(recipientEmail))
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods
|
||||
{
|
||||
public abstract class NotificationMethodBase : IHealthCheckNotificationMethod
|
||||
{
|
||||
protected NotificationMethodBase(IHealthChecks healthCheckConfig)
|
||||
protected NotificationMethodBase(IHealthChecksSettings healthCheckSettingsConfig)
|
||||
{
|
||||
var type = GetType();
|
||||
var attribute = type.GetCustomAttribute<HealthCheckNotificationMethodAttribute>();
|
||||
@@ -18,7 +18,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods
|
||||
return;
|
||||
}
|
||||
|
||||
var notificationMethods = healthCheckConfig.NotificationSettings.NotificationMethods;
|
||||
var notificationMethods = healthCheckSettingsConfig.NotificationSettings.NotificationMethods;
|
||||
var notificationMethod = notificationMethods[attribute.Alias];
|
||||
if (notificationMethod == null)
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Umbraco.Core.Logging.Serilog
|
||||
///</summary>
|
||||
public class SerilogLogger : ILogger, IDisposable
|
||||
{
|
||||
private readonly ICoreDebug _coreDebug;
|
||||
private readonly ICoreDebugSettings _coreDebugSettings;
|
||||
private readonly IIOHelper _ioHelper;
|
||||
private readonly IMarchal _marchal;
|
||||
|
||||
@@ -26,9 +26,9 @@ namespace Umbraco.Core.Logging.Serilog
|
||||
/// Initialize a new instance of the <see cref="SerilogLogger"/> class with a configuration file.
|
||||
/// </summary>
|
||||
/// <param name="logConfigFile"></param>
|
||||
public SerilogLogger(ICoreDebug coreDebug, IIOHelper ioHelper, IMarchal marchal, FileInfo logConfigFile)
|
||||
public SerilogLogger(ICoreDebugSettings coreDebugSettings, IIOHelper ioHelper, IMarchal marchal, FileInfo logConfigFile)
|
||||
{
|
||||
_coreDebug = coreDebug;
|
||||
_coreDebugSettings = coreDebugSettings;
|
||||
_ioHelper = ioHelper;
|
||||
_marchal = marchal;
|
||||
|
||||
@@ -37,9 +37,9 @@ namespace Umbraco.Core.Logging.Serilog
|
||||
.CreateLogger();
|
||||
}
|
||||
|
||||
public SerilogLogger(ICoreDebug coreDebug, IIOHelper ioHelper, IMarchal marchal, LoggerConfiguration logConfig)
|
||||
public SerilogLogger(ICoreDebugSettings coreDebugSettings, IIOHelper ioHelper, IMarchal marchal, LoggerConfiguration logConfig)
|
||||
{
|
||||
_coreDebug = coreDebug;
|
||||
_coreDebugSettings = coreDebugSettings;
|
||||
_ioHelper = ioHelper;
|
||||
_marchal = marchal;
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Umbraco.Core.Logging.Serilog
|
||||
/// Creates a logger with some pre-defined configuration and remainder from config file
|
||||
/// </summary>
|
||||
/// <remarks>Used by UmbracoApplicationBase to get its logger.</remarks>
|
||||
public static SerilogLogger CreateWithDefaultConfiguration(IHostingEnvironment hostingEnvironment, ISessionIdResolver sessionIdResolver, Func<IRequestCache> requestCacheGetter, ICoreDebug coreDebug, IIOHelper ioHelper, IMarchal marchal)
|
||||
public static SerilogLogger CreateWithDefaultConfiguration(IHostingEnvironment hostingEnvironment, ISessionIdResolver sessionIdResolver, Func<IRequestCache> requestCacheGetter, ICoreDebugSettings coreDebugSettings, IIOHelper ioHelper, IMarchal marchal)
|
||||
{
|
||||
var loggerConfig = new LoggerConfiguration();
|
||||
loggerConfig
|
||||
@@ -59,7 +59,7 @@ namespace Umbraco.Core.Logging.Serilog
|
||||
.ReadFromConfigFile()
|
||||
.ReadFromUserConfigFile();
|
||||
|
||||
return new SerilogLogger(coreDebug, ioHelper, marchal, loggerConfig);
|
||||
return new SerilogLogger(coreDebugSettings, ioHelper, marchal, loggerConfig);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -179,7 +179,7 @@ namespace Umbraco.Core.Logging.Serilog
|
||||
messageTemplate += "\r\nThe thread has been aborted, because the request has timed out.";
|
||||
|
||||
// dump if configured, or if stacktrace contains Monitor.ReliableEnter
|
||||
dump = _coreDebug.DumpOnTimeoutThreadAbort || IsMonitorEnterThreadAbortException(exception);
|
||||
dump = _coreDebugSettings.DumpOnTimeoutThreadAbort || IsMonitorEnterThreadAbortException(exception);
|
||||
|
||||
// dump if it is ok to dump (might have a cap on number of dump...)
|
||||
dump &= MiniDump.OkToDump(_ioHelper);
|
||||
|
||||
@@ -15,18 +15,18 @@ namespace Umbraco.Web.Scheduling
|
||||
private readonly HealthCheckCollection _healthChecks;
|
||||
private readonly HealthCheckNotificationMethodCollection _notifications;
|
||||
private readonly IProfilingLogger _logger;
|
||||
private readonly IHealthChecks _healthChecksConfig;
|
||||
private readonly IHealthChecksSettings _healthChecksSettingsConfig;
|
||||
|
||||
public HealthCheckNotifier(IBackgroundTaskRunner<RecurringTaskBase> runner, int delayMilliseconds, int periodMilliseconds,
|
||||
HealthCheckCollection healthChecks, HealthCheckNotificationMethodCollection notifications,
|
||||
IRuntimeState runtimeState, IProfilingLogger logger, IHealthChecks healthChecksConfig)
|
||||
IRuntimeState runtimeState, IProfilingLogger logger, IHealthChecksSettings healthChecksSettingsConfig)
|
||||
: base(runner, delayMilliseconds, periodMilliseconds)
|
||||
{
|
||||
_healthChecks = healthChecks;
|
||||
_notifications = notifications;
|
||||
_runtimeState = runtimeState;
|
||||
_logger = logger;
|
||||
_healthChecksConfig = healthChecksConfig;
|
||||
_healthChecksSettingsConfig = healthChecksSettingsConfig;
|
||||
}
|
||||
|
||||
public override async Task<bool> PerformRunAsync(CancellationToken token)
|
||||
@@ -53,7 +53,7 @@ namespace Umbraco.Web.Scheduling
|
||||
|
||||
using (_logger.DebugDuration<HealthCheckNotifier>("Health checks executing", "Health checks complete"))
|
||||
{
|
||||
var healthCheckConfig = _healthChecksConfig;
|
||||
var healthCheckConfig = _healthChecksSettingsConfig;
|
||||
|
||||
// Don't notify for any checks that are disabled, nor for any disabled
|
||||
// just for notifications
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Umbraco.Web.Scheduling
|
||||
private readonly HealthCheckCollection _healthChecks;
|
||||
private readonly HealthCheckNotificationMethodCollection _notifications;
|
||||
private readonly IUmbracoContextFactory _umbracoContextFactory;
|
||||
private readonly IHealthChecks _healthChecksConfig;
|
||||
private readonly IHealthChecksSettings _healthChecksSettingsConfig;
|
||||
private readonly IIOHelper _ioHelper;
|
||||
private readonly IServerMessenger _serverMessenger;
|
||||
private readonly IRequestAccessor _requestAccessor;
|
||||
@@ -56,7 +56,7 @@ namespace Umbraco.Web.Scheduling
|
||||
IContentService contentService, IAuditService auditService,
|
||||
HealthCheckCollection healthChecks, HealthCheckNotificationMethodCollection notifications,
|
||||
IScopeProvider scopeProvider, IUmbracoContextFactory umbracoContextFactory, IProfilingLogger logger,
|
||||
IHostingEnvironment hostingEnvironment, IHealthChecks healthChecksConfig,
|
||||
IHostingEnvironment hostingEnvironment, IHealthChecksSettings healthChecksSettingsConfig,
|
||||
IIOHelper ioHelper, IServerMessenger serverMessenger, IRequestAccessor requestAccessor,
|
||||
ILoggingSettings loggingSettings, IKeepAliveSettings keepAliveSettings)
|
||||
{
|
||||
@@ -70,7 +70,7 @@ namespace Umbraco.Web.Scheduling
|
||||
|
||||
_healthChecks = healthChecks;
|
||||
_notifications = notifications;
|
||||
_healthChecksConfig = healthChecksConfig ?? throw new ArgumentNullException(nameof(healthChecksConfig));
|
||||
_healthChecksSettingsConfig = healthChecksSettingsConfig ?? throw new ArgumentNullException(nameof(healthChecksSettingsConfig));
|
||||
_ioHelper = ioHelper;
|
||||
_serverMessenger = serverMessenger;
|
||||
_requestAccessor = requestAccessor;
|
||||
@@ -126,7 +126,7 @@ namespace Umbraco.Web.Scheduling
|
||||
tasks.Add(RegisterLogScrubber(_loggingSettings));
|
||||
tasks.Add(RegisterTempFileCleanup());
|
||||
|
||||
var healthCheckConfig = _healthChecksConfig;
|
||||
var healthCheckConfig = _healthChecksSettingsConfig;
|
||||
if (healthCheckConfig.NotificationSettings.Enabled)
|
||||
tasks.Add(RegisterHealthCheckNotifier(healthCheckConfig, _healthChecks, _notifications, _logger));
|
||||
|
||||
@@ -152,28 +152,28 @@ namespace Umbraco.Web.Scheduling
|
||||
return task;
|
||||
}
|
||||
|
||||
private IBackgroundTask RegisterHealthCheckNotifier(IHealthChecks healthCheckConfig,
|
||||
private IBackgroundTask RegisterHealthCheckNotifier(IHealthChecksSettings healthCheckSettingsConfig,
|
||||
HealthCheckCollection healthChecks, HealthCheckNotificationMethodCollection notifications,
|
||||
IProfilingLogger logger)
|
||||
{
|
||||
// If first run time not set, start with just small delay after application start
|
||||
int delayInMilliseconds;
|
||||
if (string.IsNullOrEmpty(healthCheckConfig.NotificationSettings.FirstRunTime))
|
||||
if (string.IsNullOrEmpty(healthCheckSettingsConfig.NotificationSettings.FirstRunTime))
|
||||
{
|
||||
delayInMilliseconds = DefaultDelayMilliseconds;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise start at scheduled time
|
||||
delayInMilliseconds = DateTime.Now.PeriodicMinutesFrom(healthCheckConfig.NotificationSettings.FirstRunTime) * 60 * 1000;
|
||||
delayInMilliseconds = DateTime.Now.PeriodicMinutesFrom(healthCheckSettingsConfig.NotificationSettings.FirstRunTime) * 60 * 1000;
|
||||
if (delayInMilliseconds < DefaultDelayMilliseconds)
|
||||
{
|
||||
delayInMilliseconds = DefaultDelayMilliseconds;
|
||||
}
|
||||
}
|
||||
|
||||
var periodInMilliseconds = healthCheckConfig.NotificationSettings.PeriodInHours * 60 * 60 * 1000;
|
||||
var task = new HealthCheckNotifier(_healthCheckRunner, delayInMilliseconds, periodInMilliseconds, healthChecks, notifications, _runtime, logger, _healthChecksConfig);
|
||||
var periodInMilliseconds = healthCheckSettingsConfig.NotificationSettings.PeriodInHours * 60 * 60 * 1000;
|
||||
var task = new HealthCheckNotifier(_healthCheckRunner, delayInMilliseconds, periodInMilliseconds, healthChecks, notifications, _runtime, logger, _healthChecksSettingsConfig);
|
||||
_healthCheckRunner.TryAdd(task);
|
||||
return task;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Umbraco.Core.Scoping
|
||||
internal class Scope : IScope
|
||||
{
|
||||
private readonly ScopeProvider _scopeProvider;
|
||||
private readonly ICoreDebug _coreDebug;
|
||||
private readonly ICoreDebugSettings _coreDebugSettings;
|
||||
private readonly IMediaFileSystem _mediaFileSystem;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ITypeFinder _typeFinder;
|
||||
@@ -39,7 +39,7 @@ namespace Umbraco.Core.Scoping
|
||||
|
||||
// initializes a new scope
|
||||
private Scope(ScopeProvider scopeProvider,
|
||||
ICoreDebug coreDebug,
|
||||
ICoreDebugSettings coreDebugSettings,
|
||||
IMediaFileSystem mediaFileSystem,
|
||||
ILogger logger, ITypeFinder typeFinder, FileSystems fileSystems, Scope parent, IScopeContext scopeContext, bool detachable,
|
||||
IsolationLevel isolationLevel = IsolationLevel.Unspecified,
|
||||
@@ -50,7 +50,7 @@ namespace Umbraco.Core.Scoping
|
||||
bool autoComplete = false)
|
||||
{
|
||||
_scopeProvider = scopeProvider;
|
||||
_coreDebug = coreDebug;
|
||||
_coreDebugSettings = coreDebugSettings;
|
||||
_mediaFileSystem = mediaFileSystem;
|
||||
_logger = logger;
|
||||
_typeFinder = typeFinder;
|
||||
@@ -118,7 +118,7 @@ namespace Umbraco.Core.Scoping
|
||||
|
||||
// initializes a new scope
|
||||
public Scope(ScopeProvider scopeProvider,
|
||||
ICoreDebug coreDebug,
|
||||
ICoreDebugSettings coreDebugSettings,
|
||||
IMediaFileSystem mediaFileSystem,
|
||||
ILogger logger, ITypeFinder typeFinder, FileSystems fileSystems, bool detachable, IScopeContext scopeContext,
|
||||
IsolationLevel isolationLevel = IsolationLevel.Unspecified,
|
||||
@@ -127,12 +127,12 @@ namespace Umbraco.Core.Scoping
|
||||
bool? scopeFileSystems = null,
|
||||
bool callContext = false,
|
||||
bool autoComplete = false)
|
||||
: this(scopeProvider, coreDebug, mediaFileSystem, logger, typeFinder, fileSystems, null, scopeContext, detachable, isolationLevel, repositoryCacheMode, eventDispatcher, scopeFileSystems, callContext, autoComplete)
|
||||
: this(scopeProvider, coreDebugSettings, mediaFileSystem, logger, typeFinder, fileSystems, null, scopeContext, detachable, isolationLevel, repositoryCacheMode, eventDispatcher, scopeFileSystems, callContext, autoComplete)
|
||||
{ }
|
||||
|
||||
// initializes a new scope in a nested scopes chain, with its parent
|
||||
public Scope(ScopeProvider scopeProvider,
|
||||
ICoreDebug coreDebug,
|
||||
ICoreDebugSettings coreDebugSettings,
|
||||
IMediaFileSystem mediaFileSystem,
|
||||
ILogger logger, ITypeFinder typeFinder, FileSystems fileSystems, Scope parent,
|
||||
IsolationLevel isolationLevel = IsolationLevel.Unspecified,
|
||||
@@ -141,7 +141,7 @@ namespace Umbraco.Core.Scoping
|
||||
bool? scopeFileSystems = null,
|
||||
bool callContext = false,
|
||||
bool autoComplete = false)
|
||||
: this(scopeProvider, coreDebug, mediaFileSystem, logger, typeFinder, fileSystems, parent, null, false, isolationLevel, repositoryCacheMode, eventDispatcher, scopeFileSystems, callContext, autoComplete)
|
||||
: this(scopeProvider, coreDebugSettings, mediaFileSystem, logger, typeFinder, fileSystems, parent, null, false, isolationLevel, repositoryCacheMode, eventDispatcher, scopeFileSystems, callContext, autoComplete)
|
||||
{ }
|
||||
|
||||
public Guid InstanceId { get; } = Guid.NewGuid();
|
||||
@@ -494,9 +494,9 @@ namespace Umbraco.Core.Scoping
|
||||
private static bool? _logUncompletedScopes;
|
||||
|
||||
// caching config
|
||||
// true if Umbraco.CoreDebug.LogUncompletedScope appSetting is set to "true"
|
||||
// true if Umbraco.CoreDebugSettings.LogUncompletedScope appSetting is set to "true"
|
||||
private bool LogUncompletedScopes => (_logUncompletedScopes
|
||||
?? (_logUncompletedScopes = _coreDebug.LogUncompletedScopes)).Value;
|
||||
?? (_logUncompletedScopes = _coreDebugSettings.LogUncompletedScopes)).Value;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ReadLock(params int[] lockIds) => Database.SqlContext.SqlSyntax.ReadLock(Database, lockIds);
|
||||
|
||||
@@ -26,14 +26,14 @@ namespace Umbraco.Core.Scoping
|
||||
private readonly ITypeFinder _typeFinder;
|
||||
private readonly IRequestCache _requestCache;
|
||||
private readonly FileSystems _fileSystems;
|
||||
private readonly ICoreDebug _coreDebug;
|
||||
private readonly ICoreDebugSettings _coreDebugSettings;
|
||||
private readonly IMediaFileSystem _mediaFileSystem;
|
||||
|
||||
public ScopeProvider(IUmbracoDatabaseFactory databaseFactory, FileSystems fileSystems, ICoreDebug coreDebug, IMediaFileSystem mediaFileSystem, ILogger logger, ITypeFinder typeFinder, IRequestCache requestCache)
|
||||
public ScopeProvider(IUmbracoDatabaseFactory databaseFactory, FileSystems fileSystems, ICoreDebugSettings coreDebugSettings, IMediaFileSystem mediaFileSystem, ILogger logger, ITypeFinder typeFinder, IRequestCache requestCache)
|
||||
{
|
||||
DatabaseFactory = databaseFactory;
|
||||
_fileSystems = fileSystems;
|
||||
_coreDebug = coreDebug;
|
||||
_coreDebugSettings = coreDebugSettings;
|
||||
_mediaFileSystem = mediaFileSystem;
|
||||
_logger = logger;
|
||||
_typeFinder = typeFinder;
|
||||
@@ -255,7 +255,7 @@ namespace Umbraco.Core.Scoping
|
||||
IEventDispatcher eventDispatcher = null,
|
||||
bool? scopeFileSystems = null)
|
||||
{
|
||||
return new Scope(this, _coreDebug, _mediaFileSystem, _logger, _typeFinder, _fileSystems, true, null, isolationLevel, repositoryCacheMode, eventDispatcher, scopeFileSystems);
|
||||
return new Scope(this, _coreDebugSettings, _mediaFileSystem, _logger, _typeFinder, _fileSystems, true, null, isolationLevel, repositoryCacheMode, eventDispatcher, scopeFileSystems);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -311,13 +311,13 @@ namespace Umbraco.Core.Scoping
|
||||
{
|
||||
var ambientContext = AmbientContext;
|
||||
var newContext = ambientContext == null ? new ScopeContext() : null;
|
||||
var scope = new Scope(this, _coreDebug, _mediaFileSystem, _logger, _typeFinder, _fileSystems, false, newContext, isolationLevel, repositoryCacheMode, eventDispatcher, scopeFileSystems, callContext, autoComplete);
|
||||
var scope = new Scope(this, _coreDebugSettings, _mediaFileSystem, _logger, _typeFinder, _fileSystems, false, newContext, isolationLevel, repositoryCacheMode, eventDispatcher, scopeFileSystems, callContext, autoComplete);
|
||||
// assign only if scope creation did not throw!
|
||||
SetAmbient(scope, newContext ?? ambientContext);
|
||||
return scope;
|
||||
}
|
||||
|
||||
var nested = new Scope(this, _coreDebug, _mediaFileSystem, _logger, _typeFinder, _fileSystems, ambientScope, isolationLevel, repositoryCacheMode, eventDispatcher, scopeFileSystems, callContext, autoComplete);
|
||||
var nested = new Scope(this, _coreDebugSettings, _mediaFileSystem, _logger, _typeFinder, _fileSystems, ambientScope, isolationLevel, repositoryCacheMode, eventDispatcher, scopeFileSystems, callContext, autoComplete);
|
||||
SetAmbient(nested, AmbientContext);
|
||||
return nested;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace Umbraco.Tests.Common
|
||||
public abstract IDbProviderFactoryCreator DbProviderFactoryCreator { get; }
|
||||
public abstract IBulkSqlInsertProvider BulkSqlInsertProvider { get; }
|
||||
public abstract IMarchal Marchal { get; }
|
||||
public ICoreDebug CoreDebug { get; } = new CoreDebug();
|
||||
public ICoreDebugSettings CoreDebugSettings { get; } = new CoreDebugSettings();
|
||||
|
||||
|
||||
public IIOHelper IOHelper { get; }
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Umbraco.Tests.Components
|
||||
var typeFinder = TestHelper.GetTypeFinder();
|
||||
var f = new UmbracoDatabaseFactory(logger, SettingsForTests.GetDefaultGlobalSettings(), Mock.Of<IConnectionStrings>(), new Lazy<IMapperCollection>(() => new MapperCollection(Enumerable.Empty<BaseMapper>())), TestHelper.DbProviderFactoryCreator);
|
||||
var fs = new FileSystems(mock.Object, logger, TestHelper.IOHelper, SettingsForTests.GenerateMockGlobalSettings());
|
||||
var coreDebug = Mock.Of<ICoreDebug>();
|
||||
var coreDebug = Mock.Of<ICoreDebugSettings>();
|
||||
var mediaFileSystem = Mock.Of<IMediaFileSystem>();
|
||||
var p = new ScopeProvider(f, fs, coreDebug, mediaFileSystem, logger, typeFinder, NoAppCache.Instance);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Configuration;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Configuration;
|
||||
using Umbraco.Configuration.Legacy;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
public static IDbProviderFactoryCreator DbProviderFactoryCreator => _testHelperInternal.DbProviderFactoryCreator;
|
||||
public static IBulkSqlInsertProvider BulkSqlInsertProvider => _testHelperInternal.BulkSqlInsertProvider;
|
||||
public static IMarchal Marchal => _testHelperInternal.Marchal;
|
||||
public static ICoreDebug CoreDebug => _testHelperInternal.CoreDebug;
|
||||
public static ICoreDebugSettings CoreDebugSettings => _testHelperInternal.CoreDebugSettings;
|
||||
|
||||
|
||||
public static IIOHelper IOHelper => _testHelperInternal.IOHelper;
|
||||
|
||||
@@ -255,7 +255,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
|
||||
typeFinder = typeFinder ?? new TypeFinder(logger, new DefaultUmbracoAssemblyProvider(GetType().Assembly));
|
||||
fileSystems = fileSystems ?? new FileSystems(Current.Factory, logger, TestHelper.IOHelper, SettingsForTests.GenerateMockGlobalSettings());
|
||||
var coreDebug = TestHelper.CoreDebug;
|
||||
var coreDebug = TestHelper.CoreDebugSettings;
|
||||
var mediaFileSystem = Mock.Of<IMediaFileSystem>();
|
||||
var scopeProvider = new ScopeProvider(databaseFactory, fileSystems, coreDebug, mediaFileSystem, logger, typeFinder, NoAppCache.Instance);
|
||||
return scopeProvider;
|
||||
|
||||
@@ -266,7 +266,7 @@ namespace Umbraco.Tests.Testing
|
||||
profiler = Mock.Of<IProfiler>();
|
||||
break;
|
||||
case UmbracoTestOptions.Logger.Serilog:
|
||||
logger = new SerilogLogger(TestHelper.CoreDebug, IOHelper, TestHelper.Marchal, new FileInfo(TestHelper.MapPathForTest("~/unit-test.config")));
|
||||
logger = new SerilogLogger(TestHelper.CoreDebugSettings, IOHelper, TestHelper.Marchal, new FileInfo(TestHelper.MapPathForTest("~/unit-test.config")));
|
||||
profiler = new LogProfiler(logger);
|
||||
break;
|
||||
case UmbracoTestOptions.Logger.Console:
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Umbraco.Tests.UmbracoExamine
|
||||
[OneTimeSetUp]
|
||||
public void InitializeFixture()
|
||||
{
|
||||
var logger = new SerilogLogger(TestHelper.CoreDebug, IOHelper, TestHelper.Marchal, new FileInfo(TestHelper.MapPathForTest("~/unit-test.config")));
|
||||
var logger = new SerilogLogger(TestHelper.CoreDebugSettings, IOHelper, TestHelper.Marchal, new FileInfo(TestHelper.MapPathForTest("~/unit-test.config")));
|
||||
_profilingLogger = new ProfilingLogger(logger, new LogProfiler(logger));
|
||||
}
|
||||
|
||||
|
||||
+32
-15
@@ -1,16 +1,16 @@
|
||||
using System.Configuration;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Umbraco.Composing;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Configuration;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.HealthChecks;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Logging.Serilog;
|
||||
using Umbraco.Core.Runtime;
|
||||
|
||||
namespace Umbraco.Web.BackOffice.AspNetCore
|
||||
{
|
||||
@@ -18,28 +18,43 @@ namespace Umbraco.Web.BackOffice.AspNetCore
|
||||
{
|
||||
public static IServiceCollection AddUmbracoBackOffice(this IServiceCollection services)
|
||||
{
|
||||
|
||||
|
||||
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||
|
||||
CreateCompositionRoot(services);
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
|
||||
private static void CreateCompositionRoot(IServiceCollection services)
|
||||
{
|
||||
var serviceProvider = services.BuildServiceProvider();
|
||||
|
||||
var httpContextAccessor = serviceProvider.GetService<IHttpContextAccessor>();
|
||||
var webHostEnvironment = serviceProvider.GetService<IWebHostEnvironment>();
|
||||
var hostApplicationLifetime = serviceProvider.GetService<IHostApplicationLifetime>();
|
||||
var configuration = serviceProvider.GetService<IConfiguration>();
|
||||
|
||||
var configsFactory = new AspNetCoreConfigsFactory(configuration);
|
||||
var configs = configsFactory.Create();
|
||||
|
||||
var settings = configs.GetConfig<IModelsBuilderConfig>();
|
||||
|
||||
var x =settings.ModelsDirectory;
|
||||
|
||||
|
||||
services.CreateCompositionRoot(
|
||||
httpContextAccessor,
|
||||
webHostEnvironment,
|
||||
hostApplicationLifetime,
|
||||
configsFactory);
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
|
||||
public static IServiceCollection CreateCompositionRoot(
|
||||
this IServiceCollection services,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IWebHostEnvironment webHostEnvironment,
|
||||
IHostApplicationLifetime hostApplicationLifetime,
|
||||
IConfigsFactory configsFactory)
|
||||
{
|
||||
var configFactory = new ConfigsFactory();
|
||||
|
||||
var hostingSettings = configFactory.HostingSettings;
|
||||
var coreDebug = configFactory.CoreDebug;
|
||||
var coreDebug = configFactory.CoreDebugSettings;
|
||||
var globalSettings = configFactory.GlobalSettings;
|
||||
|
||||
var hostingEnvironment = new AspNetCoreHostingEnvironment(hostingSettings, webHostEnvironment, httpContextAccessor, hostApplicationLifetime);
|
||||
@@ -51,6 +66,8 @@ namespace Umbraco.Web.BackOffice.AspNetCore
|
||||
var profiler = new LogProfiler(logger);
|
||||
|
||||
Current.Initialize(logger, configs, ioHelper, hostingEnvironment, backOfficeInfo, profiler);
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<umb-box-header title-key="redirectUrls_redirectUrlManagement"></umb-box-header>
|
||||
<umb-box-content class="block-form">
|
||||
<div style="position: relative;">
|
||||
<div ng-if="loadingRedirectUrls" style="background: rgba(255, 255, 255, 0.8); position: absolute; top: 0; left: 0; right: 0; bottom: 0;"></div>
|
||||
<div ng-if="loadingRedirectUrls" style="background: rgba(255: 255, 255, 0.8); position: absolute; top: 0; left: 0; right: 0; bottom: 0;"></div>
|
||||
<umb-load-indicator ng-if="loadingRedirectUrls"></umb-load-indicator>
|
||||
<div ng-show="hasRedirects">
|
||||
<p><localize key="redirectUrls_panelInformation" class="ng-isolate-scope ng-scope">The following URLs redirect to this content item:</localize></p>
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
<umb-box-header
|
||||
title="{{historyLabel}}">
|
||||
|
||||
|
||||
<umb-button
|
||||
ng-hide="node.trashed"
|
||||
type="button"
|
||||
@@ -64,7 +64,7 @@
|
||||
<umb-load-indicator ng-show="loadingAuditTrail"></umb-load-indicator>
|
||||
|
||||
<div ng-show="auditTrail.length === 0" style="padding: 10px;">
|
||||
<umb-empty-state
|
||||
<umb-empty-state
|
||||
position="center"
|
||||
size="small">
|
||||
<localize key="content_noChanges"></localize>
|
||||
@@ -79,7 +79,7 @@
|
||||
|
||||
<div class="history-item__break">
|
||||
<div class="history-item__avatar">
|
||||
<umb-avatar
|
||||
<umb-avatar
|
||||
color="secondary"
|
||||
size="xs"
|
||||
name="{{item.userName}}"
|
||||
@@ -105,7 +105,7 @@
|
||||
<localize key="auditTrails_{{ item.logType | lowercase }}" tokens="[item.parameters]">{{ item.comment }}</localize>
|
||||
</span>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -126,7 +126,7 @@
|
||||
</div>
|
||||
|
||||
<div class="umb-package-details__sidebar">
|
||||
|
||||
|
||||
<umb-box data-element="node-info-general">
|
||||
<umb-box-header title-key="general_general"></umb-box-header>
|
||||
<umb-box-content class="block-form">
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
|
||||
namespace Umbraco.Web.UI.BackOffice
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Umbraco.Web.BackOffice.AspNetCore;
|
||||
@@ -15,6 +16,7 @@ namespace Umbraco.Web.UI.BackOffice
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
|
||||
@@ -1,10 +1,91 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"Umbraco": {
|
||||
"CMS": {
|
||||
"HealthChecks": {
|
||||
"DisabledChecks": [
|
||||
{
|
||||
"id": "1B5D221B-CE99-4193-97CB-5F3261EC73DF",
|
||||
"disabledBy": 1,
|
||||
"disabledOn": "2020-03-15 19:19:10"
|
||||
}
|
||||
],
|
||||
"NotificationSettings": {
|
||||
"Enabled": true,
|
||||
"FirstRunTime" : "",
|
||||
"PeriodInHours": 24,
|
||||
"NotificationMethods": {
|
||||
"Email": {
|
||||
"Enabled" : true,
|
||||
"Verbosity" : "Summary",
|
||||
"Settings": {
|
||||
"RecipientEmail": ""
|
||||
}
|
||||
}
|
||||
},
|
||||
"DisabledChecks": [
|
||||
{
|
||||
"id": "1B5D221B-CE99-4193-97CB-5F3261EC73DF",
|
||||
"disabledBy": 1,
|
||||
"disabledOn": "2020-03-15 19:19:10"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"Tours": {
|
||||
"EnableTours": true
|
||||
},
|
||||
"Core": {
|
||||
"Debug": {
|
||||
|
||||
}
|
||||
},
|
||||
"Content": {
|
||||
"Errors": {
|
||||
"Error404" : {
|
||||
"default": "1047",
|
||||
"en-US":"$site/error [@name = 'error']",
|
||||
"en-UK" : "8560867F-B88F-4C74-A9A4-679D8E5B3BFC"
|
||||
}
|
||||
}
|
||||
},
|
||||
"RequestHandler": {
|
||||
"AddTrailingSlash": true,
|
||||
"CharCollection": {
|
||||
" ": "-",
|
||||
"\"":"",
|
||||
"'":"",
|
||||
"%":"",
|
||||
".":"",
|
||||
";":"",
|
||||
"/":"",
|
||||
"\\":"",
|
||||
":":"",
|
||||
"#":"",
|
||||
"+":"plus",
|
||||
"*":"star",
|
||||
"&":"",
|
||||
"?":"",
|
||||
"æ":"ae",
|
||||
"ø":"oe",
|
||||
"å":"aa",
|
||||
"ä":"ae",
|
||||
"ö":"oe",
|
||||
"ü":"ue",
|
||||
"ß":"ss",
|
||||
"|":"-",
|
||||
"<":"",
|
||||
">":""
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
|
||||
@@ -20,12 +20,12 @@ namespace Umbraco.Web.HealthCheck
|
||||
private readonly IList<Guid> _disabledCheckIds;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public HealthCheckController(HealthCheckCollection checks, ILogger logger, IHealthChecks healthChecks)
|
||||
public HealthCheckController(HealthCheckCollection checks, ILogger logger, IHealthChecksSettings healthChecksSettings)
|
||||
{
|
||||
_checks = checks ?? throw new ArgumentNullException(nameof(checks));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
|
||||
var healthCheckConfig = healthChecks ?? throw new ArgumentNullException(nameof(healthChecks));
|
||||
var healthCheckConfig = healthChecksSettings ?? throw new ArgumentNullException(nameof(healthChecksSettings));
|
||||
_disabledCheckIds = healthCheckConfig.DisabledChecks
|
||||
.Select(x => x.Id)
|
||||
.ToList();
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Umbraco.Web
|
||||
var configFactory = new ConfigsFactory();
|
||||
|
||||
var hostingSettings = configFactory.HostingSettings;
|
||||
var coreDebug = configFactory.CoreDebug;
|
||||
var coreDebug = configFactory.CoreDebugSettings;
|
||||
var globalSettings = configFactory.GlobalSettings;
|
||||
|
||||
var hostingEnvironment = new AspNetHostingEnvironment(hostingSettings);
|
||||
|
||||
Reference in New Issue
Block a user