IConfigurationManager.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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>() where T : IConfigurationFactory;
  45. /// <summary>
  46. /// Gets the configuration.
  47. /// </summary>
  48. /// <param name="key">The key.</param>
  49. /// <returns>System.Object.</returns>
  50. object GetConfiguration(string key);
  51. /// <summary>
  52. /// Gets the type of the configuration.
  53. /// </summary>
  54. /// <param name="key">The key.</param>
  55. /// <returns>Type.</returns>
  56. Type GetConfigurationType(string key);
  57. /// <summary>
  58. /// Saves the configuration.
  59. /// </summary>
  60. /// <param name="key">The key.</param>
  61. /// <param name="configuration">The configuration.</param>
  62. void SaveConfiguration(string key, object configuration);
  63. /// <summary>
  64. /// Adds the parts.
  65. /// </summary>
  66. /// <param name="factories">The factories.</param>
  67. void AddParts(IEnumerable<IConfigurationFactory> factories);
  68. }
  69. public static class ConfigurationManagerExtensions
  70. {
  71. public static T GetConfiguration<T>(this IConfigurationManager manager, string key)
  72. {
  73. return (T)manager.GetConfiguration(key);
  74. }
  75. }
  76. }