2019-10-09 08:10:16 -07:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
2019-01-13 13:01:16 -07:00
|
|
|
using System;
|
2018-12-27 16:27:57 -07:00
|
|
|
using System.Collections.Generic;
|
2019-01-13 12:25:11 -07:00
|
|
|
using MediaBrowser.Model.Configuration;
|
2018-12-27 16:27:57 -07:00
|
|
|
|
|
|
|
namespace MediaBrowser.Common.Configuration
|
|
|
|
{
|
|
|
|
public interface IConfigurationManager
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Occurs when [configuration updating].
|
|
|
|
/// </summary>
|
|
|
|
event EventHandler<ConfigurationUpdateEventArgs> NamedConfigurationUpdating;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Occurs when [configuration updated].
|
|
|
|
/// </summary>
|
|
|
|
event EventHandler<EventArgs> ConfigurationUpdated;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Occurs when [named configuration updated].
|
|
|
|
/// </summary>
|
|
|
|
event EventHandler<ConfigurationUpdateEventArgs> NamedConfigurationUpdated;
|
|
|
|
|
|
|
|
/// <summary>
|
2020-06-03 04:04:45 -07:00
|
|
|
/// Gets the application paths.
|
2018-12-27 16:27:57 -07:00
|
|
|
/// </summary>
|
|
|
|
/// <value>The application paths.</value>
|
|
|
|
IApplicationPaths CommonApplicationPaths { get; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the configuration.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The configuration.</value>
|
|
|
|
BaseApplicationConfiguration CommonConfiguration { get; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Saves the configuration.
|
|
|
|
/// </summary>
|
|
|
|
void SaveConfiguration();
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Replaces the configuration.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="newConfiguration">The new configuration.</param>
|
|
|
|
void ReplaceConfiguration(BaseApplicationConfiguration newConfiguration);
|
|
|
|
|
2020-10-11 05:19:14 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Manually pre-loads a factory so that it is available pre system initialisation.
|
|
|
|
/// </summary>
|
|
|
|
/// <typeparam name="T">Class to register.</typeparam>
|
2020-10-12 13:00:54 -07:00
|
|
|
void RegisterConfiguration<T>()
|
2020-10-12 12:56:37 -07:00
|
|
|
where T : IConfigurationFactory;
|
2020-10-11 05:19:14 -07:00
|
|
|
|
2018-12-27 16:27:57 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Gets the configuration.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="key">The key.</param>
|
|
|
|
/// <returns>System.Object.</returns>
|
|
|
|
object GetConfiguration(string key);
|
|
|
|
|
2022-04-09 07:45:13 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Gets the array of coniguration stores.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>Array of ConfigurationStore.</returns>
|
|
|
|
ConfigurationStore[] GetConfigurationStores();
|
|
|
|
|
2018-12-27 16:27:57 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Gets the type of the configuration.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="key">The key.</param>
|
|
|
|
/// <returns>Type.</returns>
|
|
|
|
Type GetConfigurationType(string key);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Saves the configuration.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="key">The key.</param>
|
|
|
|
/// <param name="configuration">The configuration.</param>
|
|
|
|
void SaveConfiguration(string key, object configuration);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Adds the parts.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="factories">The factories.</param>
|
|
|
|
void AddParts(IEnumerable<IConfigurationFactory> factories);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class ConfigurationManagerExtensions
|
|
|
|
{
|
|
|
|
public static T GetConfiguration<T>(this IConfigurationManager manager, string key)
|
|
|
|
{
|
|
|
|
return (T)manager.GetConfiguration(key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|