| | | 1 | | #pragma warning disable CS1591 |
| | | 2 | | |
| | | 3 | | using System; |
| | | 4 | | using System.Collections.Generic; |
| | | 5 | | using MediaBrowser.Model.Configuration; |
| | | 6 | | |
| | | 7 | | namespace MediaBrowser.Common.Configuration |
| | | 8 | | { |
| | | 9 | | public interface IConfigurationManager |
| | | 10 | | { |
| | | 11 | | /// <summary> |
| | | 12 | | /// Occurs when [configuration updating]. |
| | | 13 | | /// </summary> |
| | | 14 | | event EventHandler<ConfigurationUpdateEventArgs> NamedConfigurationUpdating; |
| | | 15 | | |
| | | 16 | | /// <summary> |
| | | 17 | | /// Occurs when [configuration updated]. |
| | | 18 | | /// </summary> |
| | | 19 | | event EventHandler<EventArgs> ConfigurationUpdated; |
| | | 20 | | |
| | | 21 | | /// <summary> |
| | | 22 | | /// Occurs when [named configuration updated]. |
| | | 23 | | /// </summary> |
| | | 24 | | event EventHandler<ConfigurationUpdateEventArgs> NamedConfigurationUpdated; |
| | | 25 | | |
| | | 26 | | /// <summary> |
| | | 27 | | /// Gets the application paths. |
| | | 28 | | /// </summary> |
| | | 29 | | /// <value>The application paths.</value> |
| | | 30 | | IApplicationPaths CommonApplicationPaths { get; } |
| | | 31 | | |
| | | 32 | | /// <summary> |
| | | 33 | | /// Gets the configuration. |
| | | 34 | | /// </summary> |
| | | 35 | | /// <value>The configuration.</value> |
| | | 36 | | BaseApplicationConfiguration CommonConfiguration { get; } |
| | | 37 | | |
| | | 38 | | /// <summary> |
| | | 39 | | /// Saves the configuration. |
| | | 40 | | /// </summary> |
| | | 41 | | void SaveConfiguration(); |
| | | 42 | | |
| | | 43 | | /// <summary> |
| | | 44 | | /// Replaces the configuration. |
| | | 45 | | /// </summary> |
| | | 46 | | /// <param name="newConfiguration">The new configuration.</param> |
| | | 47 | | void ReplaceConfiguration(BaseApplicationConfiguration newConfiguration); |
| | | 48 | | |
| | | 49 | | /// <summary> |
| | | 50 | | /// Manually pre-loads a factory so that it is available pre system initialisation. |
| | | 51 | | /// </summary> |
| | | 52 | | /// <typeparam name="T">Class to register.</typeparam> |
| | | 53 | | void RegisterConfiguration<T>() |
| | | 54 | | where T : IConfigurationFactory; |
| | | 55 | | |
| | | 56 | | /// <summary> |
| | | 57 | | /// Gets the configuration. |
| | | 58 | | /// </summary> |
| | | 59 | | /// <param name="key">The key.</param> |
| | | 60 | | /// <returns>System.Object.</returns> |
| | | 61 | | object GetConfiguration(string key); |
| | | 62 | | |
| | | 63 | | /// <summary> |
| | | 64 | | /// Gets the array of configuration stores. |
| | | 65 | | /// </summary> |
| | | 66 | | /// <returns>Array of ConfigurationStore.</returns> |
| | | 67 | | ConfigurationStore[] GetConfigurationStores(); |
| | | 68 | | |
| | | 69 | | /// <summary> |
| | | 70 | | /// Gets the type of the configuration. |
| | | 71 | | /// </summary> |
| | | 72 | | /// <param name="key">The key.</param> |
| | | 73 | | /// <returns>Type.</returns> |
| | | 74 | | Type GetConfigurationType(string key); |
| | | 75 | | |
| | | 76 | | /// <summary> |
| | | 77 | | /// Saves the configuration. |
| | | 78 | | /// </summary> |
| | | 79 | | /// <param name="key">The key.</param> |
| | | 80 | | /// <param name="configuration">The configuration.</param> |
| | | 81 | | void SaveConfiguration(string key, object configuration); |
| | | 82 | | |
| | | 83 | | /// <summary> |
| | | 84 | | /// Adds the parts. |
| | | 85 | | /// </summary> |
| | | 86 | | /// <param name="factories">The factories.</param> |
| | | 87 | | void AddParts(IEnumerable<IConfigurationFactory> factories); |
| | | 88 | | } |
| | | 89 | | |
| | | 90 | | public static class ConfigurationManagerExtensions |
| | | 91 | | { |
| | | 92 | | public static T GetConfiguration<T>(this IConfigurationManager manager, string key) |
| | | 93 | | { |
| | 1542 | 94 | | return (T)manager.GetConfiguration(key); |
| | | 95 | | } |
| | | 96 | | } |
| | | 97 | | } |