Move some of the config to Umbraco.Configuration
This commit is contained in:
28
src/Umbraco.Configuration/ConfigsExtensions.cs
Normal file
28
src/Umbraco.Configuration/ConfigsExtensions.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.Grid;
|
||||
using Umbraco.Core.Configuration.HealthChecks;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides extension methods for the <see cref="Configs"/> class.
|
||||
/// </summary>
|
||||
public static class ConfigsExtensions
|
||||
{
|
||||
public static IGlobalSettings Global(this Configs configs)
|
||||
=> configs.GetConfig<IGlobalSettings>();
|
||||
|
||||
public static IUmbracoSettingsSection Settings(this Configs configs)
|
||||
=> configs.GetConfig<IUmbracoSettingsSection>();
|
||||
|
||||
public static IHealthChecks HealthChecks(this Configs configs)
|
||||
=> configs.GetConfig<IHealthChecks>();
|
||||
|
||||
public static IGridConfig Grids(this Configs configs)
|
||||
=> configs.GetConfig<IGridConfig>();
|
||||
|
||||
public static CoreDebug CoreDebug(this Configs configs)
|
||||
=> configs.GetConfig<CoreDebug>();
|
||||
}
|
||||
}
|
||||
21
src/Umbraco.Configuration/ConfigsFactory.cs
Normal file
21
src/Umbraco.Configuration/ConfigsFactory.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.Configuration;
|
||||
using Umbraco.Core.Configuration.HealthChecks;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
|
||||
namespace Umbraco.Core.Configuration
|
||||
{
|
||||
public class ConfigsFactory : IConfigsFactory
|
||||
{
|
||||
public Configs Create() {
|
||||
var configs = new Configs(section => ConfigurationManager.GetSection(section));
|
||||
configs.Add<IGlobalSettings>(() => new GlobalSettings());
|
||||
configs.Add<IUmbracoSettingsSection>("umbracoConfiguration/settings");
|
||||
configs.Add<IHealthChecks>("umbracoConfiguration/HealthChecks");
|
||||
|
||||
configs.Add(() => new CoreDebug());
|
||||
configs.Add<IHealthChecks>("umbracoConfiguration/HealthChecks");
|
||||
configs.AddCoreConfigs();
|
||||
return configs;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using System.Configuration;
|
||||
|
||||
namespace Umbraco.Core.Configuration
|
||||
{
|
||||
internal class CoreDebug
|
||||
public class CoreDebug
|
||||
{
|
||||
public CoreDebug()
|
||||
{
|
||||
@@ -9,7 +9,7 @@ namespace Umbraco.Core.Configuration
|
||||
/// {element}MyValue{/element} instead of as attribute values.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
internal class InnerTextConfigurationElement<T> : RawXmlConfigurationElement
|
||||
public class InnerTextConfigurationElement<T> : RawXmlConfigurationElement
|
||||
{
|
||||
public InnerTextConfigurationElement()
|
||||
{
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Umbraco.Core.Configuration.UmbracoSettings
|
||||
{
|
||||
internal class ContentImagingElement : ConfigurationElement
|
||||
public class ContentImagingElement : ConfigurationElement
|
||||
{
|
||||
|
||||
[ConfigurationProperty("imageFileTypes")]
|
||||
@@ -12,7 +12,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
|
||||
//set the default
|
||||
GetDefaultImageFileTypes());
|
||||
|
||||
internal static string[] GetDefaultImageFileTypes()
|
||||
public static string[] GetDefaultImageFileTypes()
|
||||
{
|
||||
return new[] {"jpeg", "jpg", "gif", "bmp", "png", "tiff", "tif"};
|
||||
}
|
||||
@@ -49,7 +49,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
|
||||
}
|
||||
}
|
||||
|
||||
internal static ImagingAutoFillPropertiesCollection GetDefaultImageAutoFillProperties()
|
||||
public static ImagingAutoFillPropertiesCollection GetDefaultImageAutoFillProperties()
|
||||
{
|
||||
return new ImagingAutoFillPropertiesCollection
|
||||
{
|
||||
@@ -5,7 +5,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Core.Configuration.UmbracoSettings
|
||||
{
|
||||
internal class RequestHandlerElement : UmbracoConfigurationElement, IRequestHandlerSection
|
||||
public class RequestHandlerElement : UmbracoConfigurationElement, IRequestHandlerSection
|
||||
{
|
||||
[ConfigurationProperty("addTrailingSlash")]
|
||||
public InnerTextConfigurationElement<bool> AddTrailingSlash => GetOptionalTextElement("addTrailingSlash", true);
|
||||
@@ -38,7 +38,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
|
||||
}
|
||||
}
|
||||
|
||||
internal static CharCollection GetDefaultCharReplacements()
|
||||
public static CharCollection GetDefaultCharReplacements()
|
||||
{
|
||||
var dictionary = new Dictionary<char, string>()
|
||||
{
|
||||
@@ -1,53 +0,0 @@
|
||||
using System.IO;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.Grid;
|
||||
using Umbraco.Core.Configuration.HealthChecks;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Manifest;
|
||||
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides extension methods for the <see cref="Configs"/> class.
|
||||
/// </summary>
|
||||
public static class ConfigsExtensions
|
||||
{
|
||||
public static IGlobalSettings Global(this Configs configs)
|
||||
=> configs.GetConfig<IGlobalSettings>();
|
||||
|
||||
public static IUmbracoSettingsSection Settings(this Configs configs)
|
||||
=> configs.GetConfig<IUmbracoSettingsSection>();
|
||||
|
||||
public static IHealthChecks HealthChecks(this Configs configs)
|
||||
=> configs.GetConfig<IHealthChecks>();
|
||||
|
||||
public static IGridConfig Grids(this Configs configs)
|
||||
=> configs.GetConfig<IGridConfig>();
|
||||
|
||||
internal static CoreDebug CoreDebug(this Configs configs)
|
||||
=> configs.GetConfig<CoreDebug>();
|
||||
|
||||
public static void AddCoreConfigs(this Configs configs)
|
||||
{
|
||||
var configDir = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.Config));
|
||||
|
||||
configs.Add<IGlobalSettings>(() => new GlobalSettings());
|
||||
configs.Add<IUmbracoSettingsSection>("umbracoConfiguration/settings");
|
||||
configs.Add<IHealthChecks>("umbracoConfiguration/HealthChecks");
|
||||
|
||||
configs.Add(() => new CoreDebug());
|
||||
|
||||
// GridConfig depends on runtime caches, manifest parsers... and cannot be available during composition
|
||||
configs.Add<IGridConfig>(factory => new GridConfig(
|
||||
factory.GetInstance<ILogger>(),
|
||||
factory.GetInstance<AppCaches>(),
|
||||
configDir,
|
||||
factory.GetInstance<IManifestParser>(),
|
||||
factory.GetInstance<IRuntimeState>().Debug));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using System.Configuration;
|
||||
|
||||
namespace Umbraco.Core.Configuration
|
||||
{
|
||||
public class ConfigsFactory : IConfigsFactory
|
||||
{
|
||||
public Configs Create() {
|
||||
var configs = new Configs(section => ConfigurationManager.GetSection(section));
|
||||
configs.AddCoreConfigs();
|
||||
return configs;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user