IConfigurationManager.cs 3.1 KB

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