Click or drag to resize

ConfigurationManager Class

Class for managing configuration values. Uses a provider that defines where configuration values are stored. The default configuration manager is accessed through SystemConfiguration which uses the XmlConfigurationProvider to return values from settings stored in /Files/*.config files.
Inheritance Hierarchy

Namespace:  Dynamicweb.Configuration
Assembly:  Dynamicweb.Configuration (in Dynamicweb.Configuration.dll) Version: 4.1.3
Syntax
public class ConfigurationManager

The ConfigurationManager type exposes the following members.

Constructors
  NameDescription
Public methodConfigurationManager
Creates a new instance of ConfigurationManager.
Top
Methods
  NameDescription
Public methodAddProvider
Adds an instance of IConfigurationProvider. This enables multiple providers to contribute the the same ConfigurationManager.
Public methodAddProviderPriority
Adds an instance of IConfigurationProvider as the first provider in the provider list giving it priority over the system configuration provider. This enables multiple providers to contribute the the same ConfigurationManager.
Public methodContains
Determines whether the configuration contains the specified key.
Public methodGet Obsolete.
Gets the String value for the specified key.
Public methodGetBoolean
Gets the Boolean value for the specified key.
Public methodGetInt32
Gets the Int32 value for the specified key.
Public methodGetKeys
Gets all keys that can be used to get or set data.
Public methodGetValue
Gets the String value for the specified key.
Public methodSetT(DictionaryString, String) Obsolete.
Sets a collection configuration entries.
Public methodSetT(String, T) Obsolete.
Sets value of the entry with the specified key.
Public methodSetValue(DictionaryString, String)
Sets a collection configuration entries.
Public methodSetValueT(DictionaryString, String) Obsolete.
Sets the value.
Public methodSetValueT(String, T)
Sets value of the entry with the specified key.
Public methodTryGetT
Attempts to get the value associated with the specified key.
Top
Extension Methods
  NameDescription
Public Extension MethodAddXml (Defined by ConfigurationManagerXmlExtensions.)
Public Extension MethodAddXmlFile
Adds an xml configuration file to the configuration manager.
(Defined by ConfigurationManagerXmlExtensions.)
Top
Remarks
Implement IConfigurationProvider to add configuration providers that can store and retrieve settings from other sources.
Examples
Using the configuration manager
namespace Dynamicweb.Configuration.Examples
{
    class ConfigurationSample
    {
        void Configure()
        {
            // Setting a configuration value
            SystemConfiguration.Instance.SetValue("/Globalsettings/Modules/MyModule/Feature", true);

            // Getting a configuration setting as a string value
            string dbserver = SystemConfiguration.Instance.GetValue("/Globalsettings/System/Database/Server");

            // Getting a configuration setting as an integer value
            int maxAttempts = SystemConfiguration.Instance.GetInt32("/Globalsettings/Modules/MyModule/MaxAttempts");

            // Getting a configuration setting as a boolean value
            bool useFeature = SystemConfiguration.Instance.GetBoolean("/Globalsettings/Modules/MyModule/UseFeature");

            // Getting a configuration setting using TryGet
            string apiKey;
            if (SystemConfiguration.Instance.TryGet("/Globalsettings/Modules/MyModule/ApiKey", out apiKey))
            {
                if (!string.IsNullOrEmpty(apiKey))
                {

                }
            }
        }
    }
}
See Also