IConfigurationManager.cs 2.6 KB

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