diff options
Diffstat (limited to 'MediaBrowser.Common/Configuration')
3 files changed, 77 insertions, 1 deletions
diff --git a/MediaBrowser.Common/Configuration/ConfigurationUpdateEventArgs.cs b/MediaBrowser.Common/Configuration/ConfigurationUpdateEventArgs.cs new file mode 100644 index 000000000..310e2aa63 --- /dev/null +++ b/MediaBrowser.Common/Configuration/ConfigurationUpdateEventArgs.cs @@ -0,0 +1,18 @@ +using System; + +namespace MediaBrowser.Common.Configuration +{ + public class ConfigurationUpdateEventArgs : EventArgs + { + /// <summary> + /// Gets or sets the key. + /// </summary> + /// <value>The key.</value> + public string Key { get; set; } + /// <summary> + /// Gets or sets the new configuration. + /// </summary> + /// <value>The new configuration.</value> + public object NewConfiguration { get; set; } + } +} diff --git a/MediaBrowser.Common/Configuration/IConfigurationFactory.cs b/MediaBrowser.Common/Configuration/IConfigurationFactory.cs new file mode 100644 index 000000000..d418d0a42 --- /dev/null +++ b/MediaBrowser.Common/Configuration/IConfigurationFactory.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; + +namespace MediaBrowser.Common.Configuration +{ + public interface IConfigurationFactory + { + IEnumerable<ConfigurationStore> GetConfigurations(); + } + + public class ConfigurationStore + { + public string Key { get; set; } + + public Type ConfigurationType { get; set; } + } +} diff --git a/MediaBrowser.Common/Configuration/IConfigurationManager.cs b/MediaBrowser.Common/Configuration/IConfigurationManager.cs index 0d0759b66..25698d972 100644 --- a/MediaBrowser.Common/Configuration/IConfigurationManager.cs +++ b/MediaBrowser.Common/Configuration/IConfigurationManager.cs @@ -1,5 +1,6 @@ using MediaBrowser.Model.Configuration; using System; +using System.Collections.Generic; namespace MediaBrowser.Common.Configuration { @@ -9,7 +10,12 @@ namespace MediaBrowser.Common.Configuration /// Occurs when [configuration updated]. /// </summary> event EventHandler<EventArgs> ConfigurationUpdated; - + + /// <summary> + /// Occurs when [named configuration updated]. + /// </summary> + event EventHandler<ConfigurationUpdateEventArgs> NamedConfigurationUpdated; + /// <summary> /// Gets or sets the application paths. /// </summary> @@ -32,5 +38,40 @@ namespace MediaBrowser.Common.Configuration /// </summary> /// <param name="newConfiguration">The new configuration.</param> void ReplaceConfiguration(BaseApplicationConfiguration newConfiguration); + + /// <summary> + /// Gets the configuration. + /// </summary> + /// <param name="key">The key.</param> + /// <returns>System.Object.</returns> + object GetConfiguration(string key); + + /// <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); + } } } |
