aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs')
-rw-r--r--Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs35
1 files changed, 32 insertions, 3 deletions
diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
index fa4b3080c..8503a358e 100644
--- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
+++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
@@ -135,6 +135,35 @@ namespace Emby.Server.Implementations.AppBase
}
/// <summary>
+ /// Manually pre-loads a factory so that it is available pre system initialisation.
+ /// </summary>
+ /// <typeparam name="T">Class to register.</typeparam>
+ public virtual void RegisterConfiguration<T>()
+ {
+ if (!typeof(IConfigurationFactory).IsAssignableFrom(typeof(T)))
+ {
+ throw new ArgumentException("Parameter does not implement IConfigurationFactory");
+ }
+
+ IConfigurationFactory factory = (IConfigurationFactory)Activator.CreateInstance(typeof(T));
+
+ if (_configurationFactories == null)
+ {
+ _configurationFactories = new IConfigurationFactory[] { factory };
+ }
+ else
+ {
+ var list = _configurationFactories.ToList<IConfigurationFactory>();
+ list.Add(factory);
+ _configurationFactories = list.ToArray();
+ }
+
+ _configurationStores = _configurationFactories
+ .SelectMany(i => i.GetConfigurations())
+ .ToArray();
+ }
+
+ /// <summary>
/// Adds parts.
/// </summary>
/// <param name="factories">The configuration factories.</param>
@@ -269,7 +298,7 @@ namespace Emby.Server.Implementations.AppBase
}
/// <inheritdoc />
- public object GetConfiguration(string key, Type objectType = null)
+ public object GetConfiguration(string key)
{
return _configurations.GetOrAdd(key, k =>
{
@@ -278,12 +307,12 @@ namespace Emby.Server.Implementations.AppBase
var configurationInfo = _configurationStores
.FirstOrDefault(i => string.Equals(i.Key, key, StringComparison.OrdinalIgnoreCase));
- if (configurationInfo == null && objectType == null)
+ if (configurationInfo == null)
{
throw new ResourceNotFoundException("Configuration with key " + key + " not found.");
}
- var configurationType = configurationInfo?.ConfigurationType ?? objectType;
+ var configurationType = configurationInfo.ConfigurationType;
lock (_configurationSyncLock)
{