Move UmbracoConfig singleton to Current
This commit is contained in:
@@ -11,12 +11,14 @@ namespace Umbraco.Core.Composing.Composers
|
||||
{
|
||||
public static Composition ComposeConfiguration(this Composition composition)
|
||||
{
|
||||
composition.Register(factory => UmbracoConfig.For.UmbracoSettings());
|
||||
composition.Register(factory => factory.GetInstance<IUmbracoSettingsSection>().Content);
|
||||
composition.Register(factory => factory.GetInstance<IUmbracoSettingsSection>().Templates);
|
||||
composition.Register(factory => factory.GetInstance<IUmbracoSettingsSection>().RequestHandler);
|
||||
composition.Register(factory => UmbracoConfig.For.GlobalSettings());
|
||||
composition.Register(factory => UmbracoConfig.For.DashboardSettings());
|
||||
composition.RegisterUnique(factory => factory.GetInstance<UmbracoConfig>().Umbraco());
|
||||
composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().Content);
|
||||
composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().Templates);
|
||||
composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().RequestHandler);
|
||||
composition.RegisterUnique(factory => factory.GetInstance<UmbracoConfig>().Global());
|
||||
composition.RegisterUnique(factory => factory.GetInstance<UmbracoConfig>().Dashboards());
|
||||
composition.RegisterUnique(factory => factory.GetInstance<UmbracoConfig>().HealthChecks());
|
||||
composition.RegisterUnique(factory => factory.GetInstance<UmbracoConfig>().Grids());
|
||||
|
||||
// fixme - other sections we need to add?
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace Umbraco.Core.Composing
|
||||
/// </summary>
|
||||
public static void RegisterEssentials(this Composition composition,
|
||||
ILogger logger, IProfiler profiler, IProfilingLogger profilingLogger,
|
||||
IMainDom mainDom,
|
||||
CacheHelper appCaches,
|
||||
IUmbracoDatabaseFactory databaseFactory,
|
||||
TypeLoader typeLoader,
|
||||
@@ -25,6 +26,7 @@ namespace Umbraco.Core.Composing
|
||||
composition.RegisterUnique(logger);
|
||||
composition.RegisterUnique(profiler);
|
||||
composition.RegisterUnique(profilingLogger);
|
||||
composition.RegisterUnique(mainDom);
|
||||
composition.RegisterUnique(appCaches);
|
||||
composition.RegisterUnique(factory => factory.GetInstance<CacheHelper>().RuntimeCache);
|
||||
composition.RegisterUnique(databaseFactory);
|
||||
|
||||
@@ -28,11 +28,18 @@ namespace Umbraco.Core.Composing
|
||||
{
|
||||
private static IFactory _factory;
|
||||
|
||||
// fixme - refactor
|
||||
// we don't want Umbraco tests to die because the container has not been properly initialized,
|
||||
// for some too-important things such as IShortStringHelper or loggers, so if it's not
|
||||
// registered we setup a default one. We should really refactor our tests so that it does
|
||||
// not happen.
|
||||
|
||||
private static IShortStringHelper _shortStringHelper;
|
||||
private static ILogger _logger;
|
||||
private static IProfiler _profiler;
|
||||
private static IProfilingLogger _profilingLogger;
|
||||
private static IPublishedValueFallback _publishedValueFallback;
|
||||
private static UmbracoConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the factory.
|
||||
@@ -73,15 +80,9 @@ namespace Umbraco.Core.Composing
|
||||
|
||||
#region Getters
|
||||
|
||||
// fixme - refactor
|
||||
// we don't want Umbraco to die because the container has not been properly initialized,
|
||||
// for some too-important things such as IShortStringHelper or loggers, so if it's not
|
||||
// registered we setup a default one. We should really refactor our tests so that it does
|
||||
// not happen. Will do when we get rid of IShortStringHelper.
|
||||
|
||||
public static IShortStringHelper ShortStringHelper
|
||||
=> _shortStringHelper ?? (_shortStringHelper = _factory?.TryGetInstance<IShortStringHelper>()
|
||||
?? new DefaultShortStringHelper(new DefaultShortStringHelperConfig().WithDefault(UmbracoConfig.For.UmbracoSettings())));
|
||||
?? new DefaultShortStringHelper(new DefaultShortStringHelperConfig().WithDefault(Config.Umbraco())));
|
||||
|
||||
public static ILogger Logger
|
||||
=> _logger ?? (_logger = _factory?.TryGetInstance<ILogger>()
|
||||
@@ -101,6 +102,10 @@ namespace Umbraco.Core.Composing
|
||||
public static TypeLoader TypeLoader
|
||||
=> Factory.GetInstance<TypeLoader>();
|
||||
|
||||
public static UmbracoConfig Config
|
||||
=> _config ?? (_config = _factory?.TryGetInstance<UmbracoConfig>())
|
||||
?? (_config = new UmbracoConfig(Logger, _factory?.TryGetInstance<IRuntimeCacheProvider>(), _factory?.TryGetInstance<IRuntimeState>()));
|
||||
|
||||
public static IFileSystems FileSystems
|
||||
=> Factory.GetInstance<IFileSystems>();
|
||||
|
||||
|
||||
@@ -7,190 +7,132 @@ using Umbraco.Core.Configuration.Grid;
|
||||
using Umbraco.Core.Configuration.HealthChecks;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
|
||||
namespace Umbraco.Core.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// The gateway to all umbraco configuration
|
||||
/// The gateway to all umbraco configuration.
|
||||
/// </summary>
|
||||
/// <remarks>This should be registered as a unique service in the container.</remarks>
|
||||
public class UmbracoConfig
|
||||
{
|
||||
#region Singleton
|
||||
|
||||
private static readonly Lazy<UmbracoConfig> Lazy = new Lazy<UmbracoConfig>(() => new UmbracoConfig());
|
||||
|
||||
public static UmbracoConfig For => Lazy.Value;
|
||||
|
||||
#endregion
|
||||
private IGlobalSettings _global;
|
||||
private Lazy<IUmbracoSettingsSection> _umbraco;
|
||||
private Lazy<IHealthChecks> _healthChecks;
|
||||
private Lazy<IDashboardSection> _dashboards;
|
||||
private Lazy<IGridConfig> _grids;
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// Initializes a new instance of the <see cref="UmbracoConfig"/> class.
|
||||
/// </summary>
|
||||
private UmbracoConfig()
|
||||
public UmbracoConfig(ILogger logger, IRuntimeCacheProvider runtimeCache, IRuntimeState runtimeState)
|
||||
{
|
||||
_global = new GlobalSettings();
|
||||
|
||||
var appPluginsDir = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.AppPlugins));
|
||||
var configDir = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.Config));
|
||||
|
||||
_umbraco = new Lazy<IUmbracoSettingsSection>(() => GetConfig<IUmbracoSettingsSection>("umbracoConfiguration/settings"));
|
||||
_dashboards = new Lazy<IDashboardSection>(() =>GetConfig<IDashboardSection>("umbracoConfiguration/dashBoard"));
|
||||
_healthChecks = new Lazy<IHealthChecks>(() => GetConfig<IHealthChecks>("umbracoConfiguration/HealthChecks"));
|
||||
_grids = new Lazy<IGridConfig>(() => new GridConfig(logger, runtimeCache, appPluginsDir, configDir, runtimeState.Debug));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a typed and named config section.
|
||||
/// </summary>
|
||||
/// <typeparam name="TConfig">The type of the configuration section.</typeparam>
|
||||
/// <param name="sectionName">The name of the configuration section.</param>
|
||||
/// <returns>The configuration section.</returns>
|
||||
public static TConfig GetConfig<TConfig>(string sectionName)
|
||||
where TConfig : class
|
||||
{
|
||||
// note: need to use SafeCallContext here because ConfigurationManager.GetSection ends up getting AppDomain.Evidence
|
||||
// which will want to serialize the call context including anything that is in there - what a mess!
|
||||
|
||||
if (_umbracoSettings == null)
|
||||
using (new SafeCallContext())
|
||||
{
|
||||
IUmbracoSettingsSection umbracoSettings;
|
||||
using (new SafeCallContext())
|
||||
{
|
||||
umbracoSettings = ConfigurationManager.GetSection("umbracoConfiguration/settings") as IUmbracoSettingsSection;
|
||||
}
|
||||
SetUmbracoSettings(umbracoSettings);
|
||||
}
|
||||
|
||||
if (_dashboardSection == null)
|
||||
{
|
||||
IDashboardSection dashboardConfig;
|
||||
using (new SafeCallContext())
|
||||
{
|
||||
dashboardConfig = ConfigurationManager.GetSection("umbracoConfiguration/dashBoard") as IDashboardSection;
|
||||
}
|
||||
SetDashboardSettings(dashboardConfig);
|
||||
}
|
||||
|
||||
if (_healthChecks == null)
|
||||
{
|
||||
var healthCheckConfig = ConfigurationManager.GetSection("umbracoConfiguration/HealthChecks") as IHealthChecks;
|
||||
SetHealthCheckSettings(healthCheckConfig);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor - can be used for testing
|
||||
/// </summary>
|
||||
/// <param name="umbracoSettings"></param>
|
||||
/// <param name="dashboardSettings"></param>
|
||||
/// <param name="healthChecks"></param>
|
||||
/// <param name="globalSettings"></param>
|
||||
public UmbracoConfig(IUmbracoSettingsSection umbracoSettings, IDashboardSection dashboardSettings, IHealthChecks healthChecks, IGlobalSettings globalSettings)
|
||||
{
|
||||
SetHealthCheckSettings(healthChecks);
|
||||
SetUmbracoSettings(umbracoSettings);
|
||||
SetDashboardSettings(dashboardSettings);
|
||||
SetGlobalConfig(globalSettings);
|
||||
}
|
||||
|
||||
private IHealthChecks _healthChecks;
|
||||
private IDashboardSection _dashboardSection;
|
||||
private IUmbracoSettingsSection _umbracoSettings;
|
||||
private IGridConfig _gridConfig;
|
||||
private IGlobalSettings _globalSettings;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the IHealthCheck config
|
||||
/// </summary>
|
||||
public IHealthChecks HealthCheck()
|
||||
{
|
||||
if (_healthChecks == null)
|
||||
{
|
||||
var ex = new ConfigurationErrorsException("Could not load the " + typeof(IHealthChecks) + " from config file, ensure the web.config and healthchecks.config files are formatted correctly");
|
||||
if ((ConfigurationManager.GetSection(sectionName) is TConfig config))
|
||||
return config;
|
||||
var ex = new ConfigurationErrorsException($"Could not get configuration section \"{sectionName}\" from config files.");
|
||||
Current.Logger.Error<UmbracoConfig>(ex, "Config error");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
return _healthChecks;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the IDashboardSection
|
||||
/// Gets the global configuration.
|
||||
/// </summary>
|
||||
public IDashboardSection DashboardSettings()
|
||||
{
|
||||
if (_dashboardSection == null)
|
||||
{
|
||||
var ex = new ConfigurationErrorsException("Could not load the " + typeof(IDashboardSection) + " from config file, ensure the web.config and Dashboard.config files are formatted correctly");
|
||||
Current.Logger.Error<UmbracoConfig>(ex, "Config error");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
return _dashboardSection;
|
||||
}
|
||||
public IGlobalSettings Global()
|
||||
=> _global;
|
||||
|
||||
/// <summary>
|
||||
/// Only for testing
|
||||
/// Gets the Umbraco configuration.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void SetDashboardSettings(IDashboardSection value)
|
||||
{
|
||||
_dashboardSection = value;
|
||||
}
|
||||
public IUmbracoSettingsSection Umbraco()
|
||||
=> _umbraco.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Only for testing
|
||||
/// Gets the dashboards configuration.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void SetHealthCheckSettings(IHealthChecks value)
|
||||
{
|
||||
_healthChecks = value;
|
||||
}
|
||||
public IDashboardSection Dashboards()
|
||||
=> _dashboards.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Only for testing
|
||||
/// Gets the health checks configuration.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void SetUmbracoSettings(IUmbracoSettingsSection value)
|
||||
{
|
||||
_umbracoSettings = value;
|
||||
}
|
||||
public IHealthChecks HealthChecks()
|
||||
=> _healthChecks.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Only for testing
|
||||
/// Gets the grids configuration.
|
||||
/// </summary>
|
||||
public IGridConfig Grids()
|
||||
=> _grids.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the global configuration, for tests only.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void SetGlobalConfig(IGlobalSettings value)
|
||||
{
|
||||
_globalSettings = value;
|
||||
_global = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the IGlobalSettings
|
||||
/// Sets the Umbraco configuration, for tests only.
|
||||
/// </summary>
|
||||
public IGlobalSettings GlobalSettings()
|
||||
public void SetUmbracoConfig(IUmbracoSettingsSection value)
|
||||
{
|
||||
return _globalSettings ?? (_globalSettings = new GlobalSettings());
|
||||
_umbraco = new Lazy<IUmbracoSettingsSection>(() => value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the IUmbracoSettings
|
||||
/// </summary>
|
||||
public IUmbracoSettingsSection UmbracoSettings()
|
||||
{
|
||||
if (_umbracoSettings == null)
|
||||
{
|
||||
var ex = new ConfigurationErrorsException("Could not load the " + typeof (IUmbracoSettingsSection) + " from config file, ensure the web.config and umbracoSettings.config files are formatted correctly");
|
||||
Current.Logger.Error<UmbracoConfig>(ex, "Config error");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
return _umbracoSettings;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Only for testing
|
||||
/// Sets the dashboards configuration, for tests only.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void SetGridConfig(IGridConfig value)
|
||||
public void SetDashboardsConfig(IDashboardSection value)
|
||||
{
|
||||
_gridConfig = value;
|
||||
_dashboards = new Lazy<IDashboardSection>(() => value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the IGridConfig
|
||||
/// Sets the health checks configuration, for tests only.
|
||||
/// </summary>
|
||||
public IGridConfig GridConfig(ILogger logger, IRuntimeCacheProvider runtimeCache, DirectoryInfo appPlugins, DirectoryInfo configFolder, bool isDebug)
|
||||
public void SetHealthChecksConfig(IHealthChecks value)
|
||||
{
|
||||
if (_gridConfig == null)
|
||||
{
|
||||
_gridConfig = new GridConfig(logger, runtimeCache, appPlugins, configFolder, isDebug);
|
||||
}
|
||||
_healthChecks = new Lazy<IHealthChecks>(() => value);
|
||||
}
|
||||
|
||||
return _gridConfig;
|
||||
/// <summary>
|
||||
/// Sets the grids configuration, for tests only.
|
||||
/// </summary>
|
||||
public void SetGridsConfig(IGridConfig value)
|
||||
{
|
||||
_grids = new Lazy<IGridConfig>(() => value);
|
||||
}
|
||||
|
||||
//TODO: Add other configurations here !
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Core.IO.MediaPathSchemes
|
||||
@@ -30,7 +31,7 @@ namespace Umbraco.Core.IO.MediaPathSchemes
|
||||
// prevpath should be "<int>/<filename>" OR "<int>-<filename>"
|
||||
// and we want to reuse the "<int>" part, so try to find it
|
||||
|
||||
var sep = UmbracoConfig.For.UmbracoSettings().Content.UploadAllowDirectories ? "/" : "-";
|
||||
var sep = Current.Config.Umbraco().Content.UploadAllowDirectories ? "/" : "-";
|
||||
var pos = previous.IndexOf(sep, StringComparison.Ordinal);
|
||||
var s = pos > 0 ? previous.Substring(0, pos) : null;
|
||||
|
||||
@@ -44,7 +45,7 @@ namespace Umbraco.Core.IO.MediaPathSchemes
|
||||
if (directory == null)
|
||||
throw new InvalidOperationException("Cannot use a null directory.");
|
||||
|
||||
return UmbracoConfig.For.UmbracoSettings().Content.UploadAllowDirectories
|
||||
return Current.Config.Umbraco().Content.UploadAllowDirectories
|
||||
? Path.Combine(directory, filename).Replace('\\', '/')
|
||||
: directory + "-" + filename;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Reflection;
|
||||
using System.Threading;
|
||||
using Serilog;
|
||||
using Serilog.Events;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Diagnostics;
|
||||
|
||||
@@ -165,7 +166,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 = UmbracoConfig.For.CoreDebug().DumpOnTimeoutThreadAbort || IsMonitorEnterThreadAbortException(exception);
|
||||
dump = Current.Config.CoreDebug().DumpOnTimeoutThreadAbort || IsMonitorEnterThreadAbortException(exception);
|
||||
|
||||
// dump if it is ok to dump (might have a cap on number of dump...)
|
||||
dump &= MiniDump.OkToDump();
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Umbraco.Core
|
||||
/// <para>When an AppDomain starts, it tries to acquire the main domain status.</para>
|
||||
/// <para>When an AppDomain stops (eg the application is restarting) it should release the main domain status.</para>
|
||||
/// </remarks>
|
||||
internal class MainDom : IRegisteredObject
|
||||
internal class MainDom : IMainDom, IRegisteredObject
|
||||
{
|
||||
#region Vars
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
@@ -66,7 +67,7 @@ namespace Umbraco.Core.Models.Identity
|
||||
_startContentIds = new int[] { };
|
||||
_groups = new IReadOnlyUserGroup[] { };
|
||||
_allowedSections = new string[] { };
|
||||
_culture = UmbracoConfig.For.GlobalSettings().DefaultUILanguage; //fixme inject somehow?
|
||||
_culture = Current.Config.Global().DefaultUILanguage; //fixme inject somehow?
|
||||
_groups = new IReadOnlyUserGroup[0];
|
||||
_roles = new ObservableCollection<IdentityUserRole<string>>();
|
||||
_roles.CollectionChanged += _roles_CollectionChanged;
|
||||
@@ -83,7 +84,7 @@ namespace Umbraco.Core.Models.Identity
|
||||
_startContentIds = new int[] { };
|
||||
_groups = new IReadOnlyUserGroup[] { };
|
||||
_allowedSections = new string[] { };
|
||||
_culture = UmbracoConfig.For.GlobalSettings().DefaultUILanguage; //fixme inject somehow?
|
||||
_culture = Current.Config.Global().DefaultUILanguage; //fixme inject somehow?
|
||||
_groups = groups.ToArray();
|
||||
_roles = new ObservableCollection<IdentityUserRole<string>>(_groups.Select(x => new IdentityUserRole<string>
|
||||
{
|
||||
@@ -442,6 +443,6 @@ namespace Umbraco.Core.Models.Identity
|
||||
groups => groups.GetHashCode());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Umbraco.Core.Models.Membership
|
||||
{
|
||||
SessionTimeout = 60;
|
||||
_userGroups = new HashSet<IReadOnlyUserGroup>();
|
||||
_language = UmbracoConfig.For.GlobalSettings().DefaultUILanguage; //fixme inject somehow?
|
||||
_language = Current.Config.Global().DefaultUILanguage; //fixme inject somehow?
|
||||
_isApproved = true;
|
||||
_isLockedOut = false;
|
||||
_startContentIds = new int[] { };
|
||||
@@ -453,7 +453,7 @@ namespace Umbraco.Core.Models.Membership
|
||||
base.PerformDeepClone(clone);
|
||||
|
||||
var clonedEntity = (User)clone;
|
||||
|
||||
|
||||
//manually clone the start node props
|
||||
clonedEntity._startContentIds = _startContentIds.ToArray();
|
||||
clonedEntity._startMediaIds = _startMediaIds.ToArray();
|
||||
@@ -483,7 +483,7 @@ namespace Umbraco.Core.Models.Membership
|
||||
//need to create new collections otherwise they'll get copied by ref
|
||||
clonedEntity._userGroups = new HashSet<IReadOnlyUserGroup>(_userGroups);
|
||||
clonedEntity._allowedSections = _allowedSections != null ? new List<string>(_allowedSections) : null;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -7,6 +7,7 @@ using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration.Grid;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
@@ -19,9 +20,13 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
|
||||
[DefaultPropertyValueConverter(typeof(JsonValueConverter))] //this shadows the JsonValueConverter
|
||||
public class GridValueConverter : JsonValueConverter
|
||||
{
|
||||
public GridValueConverter(PropertyEditorCollection propertyEditors)
|
||||
private readonly IGridConfig _config;
|
||||
|
||||
public GridValueConverter(PropertyEditorCollection propertyEditors, IGridConfig config)
|
||||
: base(propertyEditors)
|
||||
{ }
|
||||
{
|
||||
_config = config;
|
||||
}
|
||||
|
||||
public override bool IsConverter(PublishedPropertyType propertyType)
|
||||
=> propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.Grid);
|
||||
@@ -46,15 +51,6 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
|
||||
//so we have the grid json... we need to merge in the grid's configuration values with the values
|
||||
// we've saved in the database so that when the front end gets this value, it is up-to-date.
|
||||
|
||||
//TODO: Change all singleton access to use ctor injection in v8!!!
|
||||
//TODO: That would mean that property value converters would need to be request lifespan, hrm....
|
||||
var gridConfig = UmbracoConfig.For.GridConfig(
|
||||
Current.ProfilingLogger,
|
||||
Current.ApplicationCache.RuntimeCache,
|
||||
new DirectoryInfo(IOHelper.MapPath(SystemDirectories.AppPlugins)),
|
||||
new DirectoryInfo(IOHelper.MapPath(SystemDirectories.Config)),
|
||||
Current.RuntimeState.Debug);
|
||||
|
||||
var sections = GetArray(obj, "sections");
|
||||
foreach (var section in sections.Cast<JObject>())
|
||||
{
|
||||
@@ -74,7 +70,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
|
||||
if (alias.IsNullOrWhiteSpace() == false)
|
||||
{
|
||||
//find the alias in config
|
||||
var found = gridConfig.EditorsConfig.Editors.FirstOrDefault(x => x.Alias == alias);
|
||||
var found = _config.EditorsConfig.Editors.FirstOrDefault(x => x.Alias == alias);
|
||||
if (found != null)
|
||||
{
|
||||
//add/replace the editor value with the one from config
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Umbraco.Core.Runtime
|
||||
var databaseFactory = GetDatabaseFactory();
|
||||
|
||||
// type loader
|
||||
var globalSettings = UmbracoConfig.For.GlobalSettings();
|
||||
var globalSettings = Current.Config.Global();
|
||||
var localTempStorage = globalSettings.LocalTempStorageLocation;
|
||||
var typeLoader = new TypeLoader(runtimeCache, localTempStorage, profilingLogger);
|
||||
|
||||
@@ -77,16 +77,19 @@ namespace Umbraco.Core.Runtime
|
||||
// beware! must use '() => _factory.GetInstance<T>()' and NOT '_factory.GetInstance<T>'
|
||||
// as the second one captures the current value (null) and therefore fails
|
||||
_state = new RuntimeState(logger,
|
||||
UmbracoConfig.For.UmbracoSettings(), UmbracoConfig.For.GlobalSettings(),
|
||||
Current.Config.Umbraco(), Current.Config.Global(),
|
||||
new Lazy<MainDom>(() => _factory.GetInstance<MainDom>()),
|
||||
new Lazy<IServerRegistrar>(() => _factory.GetInstance<IServerRegistrar>()))
|
||||
{
|
||||
Level = RuntimeLevel.Boot
|
||||
};
|
||||
|
||||
// main dom
|
||||
var mainDom = new MainDom(logger);
|
||||
|
||||
// create the composition
|
||||
var composition = new Composition(register, typeLoader, profilingLogger, _state);
|
||||
composition.RegisterEssentials(logger, profiler, profilingLogger, appCaches, databaseFactory, typeLoader, _state);
|
||||
composition.RegisterEssentials(logger, profiler, profilingLogger, mainDom, appCaches, databaseFactory, typeLoader, _state);
|
||||
|
||||
// register runtime-level services
|
||||
// there should be none, really - this is here "just in case"
|
||||
@@ -113,8 +116,7 @@ namespace Umbraco.Core.Runtime
|
||||
|
||||
logger.Debug<CoreRuntime>("Runtime: {Runtime}", GetType().FullName);
|
||||
|
||||
var mainDom = AquireMainDom();
|
||||
composition.RegisterUnique(mainDom);
|
||||
AquireMainDom(mainDom);
|
||||
|
||||
DetermineRuntimeLevel(databaseFactory);
|
||||
|
||||
@@ -195,15 +197,13 @@ namespace Umbraco.Core.Runtime
|
||||
IOHelper.SetRootDirectory(path);
|
||||
}
|
||||
|
||||
private MainDom AquireMainDom()
|
||||
private void AquireMainDom(MainDom mainDom)
|
||||
{
|
||||
using (var timer = ProfilingLogger.DebugDuration<CoreRuntime>("Acquiring MainDom.", "Acquired."))
|
||||
{
|
||||
try
|
||||
{
|
||||
var mainDom = new MainDom(Logger);
|
||||
mainDom.Acquire();
|
||||
return mainDom;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Events;
|
||||
using Umbraco.Core.IO;
|
||||
@@ -491,7 +492,7 @@ namespace Umbraco.Core.Scoping
|
||||
// caching config
|
||||
// true if Umbraco.CoreDebug.LogUncompletedScope appSetting is set to "true"
|
||||
private static bool LogUncompletedScopes => (_logUncompletedScopes
|
||||
?? (_logUncompletedScopes = UmbracoConfig.For.CoreDebug().LogUncompletedScopes)).Value;
|
||||
?? (_logUncompletedScopes = Current.Config.CoreDebug().LogUncompletedScopes)).Value;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ReadLock(params int[] lockIds)
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Threading;
|
||||
using System.Web;
|
||||
using System.Web.Hosting;
|
||||
using System.Web.Security;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Services;
|
||||
@@ -87,11 +88,11 @@ namespace Umbraco.Core.Security
|
||||
/// <returns></returns>
|
||||
public static MembershipProvider GetUsersMembershipProvider()
|
||||
{
|
||||
if (Membership.Providers[UmbracoConfig.For.UmbracoSettings().Providers.DefaultBackOfficeUserProvider] == null)
|
||||
if (Membership.Providers[Current.Config.Umbraco().Providers.DefaultBackOfficeUserProvider] == null)
|
||||
{
|
||||
throw new InvalidOperationException("No membership provider found with name " + UmbracoConfig.For.UmbracoSettings().Providers.DefaultBackOfficeUserProvider);
|
||||
throw new InvalidOperationException("No membership provider found with name " + Current.Config.Umbraco().Providers.DefaultBackOfficeUserProvider);
|
||||
}
|
||||
return Membership.Providers[UmbracoConfig.For.UmbracoSettings().Providers.DefaultBackOfficeUserProvider];
|
||||
return Membership.Providers[Current.Config.Umbraco().Providers.DefaultBackOfficeUserProvider];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1115,7 +1115,7 @@ namespace Umbraco.Core
|
||||
/// <remarks>Checks <c>UmbracoSettings.ForceSafeAliases</c> to determine whether it should filter the text.</remarks>
|
||||
public static string ToSafeAliasWithForcingCheck(this string alias)
|
||||
{
|
||||
return UmbracoConfig.For.UmbracoSettings().Content.ForceSafeAliases ? alias.ToSafeAlias() : alias;
|
||||
return Current.Config.Umbraco().Content.ForceSafeAliases ? alias.ToSafeAlias() : alias;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1127,7 +1127,7 @@ namespace Umbraco.Core
|
||||
/// <remarks>Checks <c>UmbracoSettings.ForceSafeAliases</c> to determine whether it should filter the text.</remarks>
|
||||
public static string ToSafeAliasWithForcingCheck(this string alias, string culture)
|
||||
{
|
||||
return UmbracoConfig.For.UmbracoSettings().Content.ForceSafeAliases ? alias.ToSafeAlias(culture) : alias;
|
||||
return Current.Config.Umbraco().Content.ForceSafeAliases ? alias.ToSafeAlias(culture) : alias;
|
||||
}
|
||||
|
||||
// the new methods to get a url segment
|
||||
|
||||
Reference in New Issue
Block a user