IConfigurationManager.cs 2.6 KB

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