aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common/Configuration/IConfigurationManager.cs
blob: fc63d93503b80cfc5626784a9ca11146a3034902 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#pragma warning disable CS1591

using System;
using System.Collections.Generic;
using MediaBrowser.Model.Configuration;

namespace MediaBrowser.Common.Configuration
{
    public interface IConfigurationManager
    {
        /// <summary>
        /// Occurs when [configuration updating].
        /// </summary>
        event EventHandler<ConfigurationUpdateEventArgs> NamedConfigurationUpdating;

        /// <summary>
        /// Occurs when [configuration updated].
        /// </summary>
        event EventHandler<EventArgs> ConfigurationUpdated;

        /// <summary>
        /// Occurs when [named configuration updated].
        /// </summary>
        event EventHandler<ConfigurationUpdateEventArgs> NamedConfigurationUpdated;

        /// <summary>
        /// Gets the application paths.
        /// </summary>
        /// <value>The application paths.</value>
        IApplicationPaths CommonApplicationPaths { get; }

        /// <summary>
        /// Gets the configuration.
        /// </summary>
        /// <value>The configuration.</value>
        BaseApplicationConfiguration CommonConfiguration { get; }

        /// <summary>
        /// Saves the configuration.
        /// </summary>
        void SaveConfiguration();

        /// <summary>
        /// Replaces the configuration.
        /// </summary>
        /// <param name="newConfiguration">The new configuration.</param>
        void ReplaceConfiguration(BaseApplicationConfiguration newConfiguration);

        /// <summary>
        /// Manually pre-loads a factory so that it is available pre system initialisation.
        /// </summary>
        /// <typeparam name="T">Class to register.</typeparam>
        void RegisterConfiguration<T>()
            where T : IConfigurationFactory;

        /// <summary>
        /// Gets the configuration.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <returns>System.Object.</returns>
        object GetConfiguration(string key);

        /// <summary>
        /// Gets the type of the configuration.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <returns>Type.</returns>
        Type GetConfigurationType(string key);

        /// <summary>
        /// Saves the configuration.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="configuration">The configuration.</param>
        void SaveConfiguration(string key, object configuration);

        /// <summary>
        /// Adds the parts.
        /// </summary>
        /// <param name="factories">The factories.</param>
        void AddParts(IEnumerable<IConfigurationFactory> factories);
    }

    public static class ConfigurationManagerExtensions
    {
        public static T GetConfiguration<T>(this IConfigurationManager manager, string key)
        {
            return (T)manager.GetConfiguration(key);
        }
    }
}