Move Configs to abstractions, and injected factory all over to create one because we need to inject stuff from system.configuration
This commit is contained in:
@@ -27,19 +27,12 @@ namespace Umbraco.Core.Composing
|
||||
/// <param name="logger">A logger.</param>
|
||||
/// <param name="runtimeState">The runtime state.</param>
|
||||
/// <param name="configs">Optional configs.</param>
|
||||
public Composition(IRegister register, TypeLoader typeLoader, IProfilingLogger logger, IRuntimeState runtimeState, Configs configs = null)
|
||||
public Composition(IRegister register, TypeLoader typeLoader, IProfilingLogger logger, IRuntimeState runtimeState, Configs configs)
|
||||
{
|
||||
_register = register;
|
||||
TypeLoader = typeLoader;
|
||||
Logger = logger;
|
||||
RuntimeState = runtimeState;
|
||||
|
||||
if (configs == null)
|
||||
{
|
||||
configs = new Configs();
|
||||
configs.AddCoreConfigs();
|
||||
}
|
||||
|
||||
Configs = configs;
|
||||
}
|
||||
|
||||
|
||||
14
src/Umbraco.Core/Composing/ConfigsFactory.cs
Normal file
14
src/Umbraco.Core/Composing/ConfigsFactory.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Core.Composing
|
||||
{
|
||||
public class ConfigsFactory : IConfigsFactory
|
||||
{
|
||||
public Configs Create() {
|
||||
var configs = new Configs(section => ConfigurationManager.GetSection(section));
|
||||
configs.AddCoreConfigs();
|
||||
return configs;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,11 +93,11 @@ namespace Umbraco.Core.Composing
|
||||
/// <para>Unlocks <see cref="Configs"/> so that it is possible to add configurations
|
||||
/// directly to <see cref="Current"/> without having to wire composition.</para>
|
||||
/// </remarks>
|
||||
public static void UnlockConfigs()
|
||||
public static void UnlockConfigs(IConfigsFactory configsFactory)
|
||||
{
|
||||
if (_factory != null)
|
||||
throw new InvalidOperationException("Cannot unlock configs when a factory has been set.");
|
||||
_configs = new Configs();
|
||||
_configs = configsFactory.Create();
|
||||
}
|
||||
|
||||
internal static event EventHandler Resetted;
|
||||
|
||||
9
src/Umbraco.Core/Composing/IConfigsFactory.cs
Normal file
9
src/Umbraco.Core/Composing/IConfigsFactory.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Core.Composing
|
||||
{
|
||||
public interface IConfigsFactory
|
||||
{
|
||||
Configs Create();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user