Click or drag to resize

SystemConfiguration Class

Provides access to all settings in GlobalSettings.aspx and .config files located in the /Files folder. Uses the XmlConfigurationProvider to return values from settings stored in xml files.
Inheritance Hierarchy

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

The SystemConfiguration type exposes the following members.

Properties
  NameDescription
Public propertyStatic memberFilesDirectory Obsolete.
Gets or sets the full path for the folder containing the configuration files.
Public propertyStatic memberInstance
Gets the current instance of the system configuration manager with data loaded from configuration files.
Top
Methods
  NameDescription
Public methodAddProvider
Adds an instance of IConfigurationProvider. This enables multiple providers to contribute the the same ConfigurationManager.
(Inherited from 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.
(Inherited from ConfigurationManager.)
Public methodContains
Determines whether the configuration contains the specified key.
(Inherited from ConfigurationManager.)
Public methodGet Obsolete.
Gets the String value for the specified key.
(Inherited from ConfigurationManager.)
Public methodGetBoolean
Gets the Boolean value for the specified key.
(Inherited from ConfigurationManager.)
Public methodGetInt32
Gets the Int32 value for the specified key.
(Inherited from ConfigurationManager.)
Public methodGetKeys
Gets all keys that can be used to get or set data.
(Inherited from ConfigurationManager.)
Public methodGetValue
Gets the String value for the specified key.
(Inherited from ConfigurationManager.)
Public methodStatic memberReset
Resets the system configuration instance and reloads settings from configuration files.
Public methodSetT(DictionaryString, String) Obsolete.
Sets a collection configuration entries.
(Inherited from ConfigurationManager.)
Public methodSetT(String, T) Obsolete.
Sets value of the entry with the specified key.
(Inherited from ConfigurationManager.)
Public methodSetValueT(DictionaryString, String) Obsolete.
Sets the value.
(Inherited from ConfigurationManager.)
Public methodSetValueT(String, T)
Sets value of the entry with the specified key.
(Inherited from ConfigurationManager.)
Public methodTryGetT
Attempts to get the value associated with the specified key.
(Inherited from ConfigurationManager.)
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
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