2
0

IConfigurationManager.cs 2.5 KB

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