IConfigurationManager.cs 2.4 KB

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