Table of Contents

Class ConfigurationManagerExtensions

Namespace
Songhay.Extensions
Assembly
SonghayCore.dll

Extensions of ConfigurationManager

public static class ConfigurationManagerExtensions
Inheritance
ConfigurationManagerExtensions
Inherited Members

Remarks

Several members in this class depend on DeploymentEnvironment constants.

Methods

GetConnectionNameFromEnvironment(ConnectionStringSettingsCollection?, string?, string?)

Gets the connection name from environment.

public static string? GetConnectionNameFromEnvironment(this ConnectionStringSettingsCollection? collection, string? unqualifiedKey, string? environmentName)

Parameters

collection ConnectionStringSettingsCollection

The collection.

unqualifiedKey string

The unqualified key.

environmentName string

Name of the environment.

Returns

string

GetConnectionNameFromEnvironment(ConnectionStringSettingsCollection?, string?, string?, bool)

Gets the connection name from environment.

public static string? GetConnectionNameFromEnvironment(this ConnectionStringSettingsCollection? collection, string? unqualifiedKey, string? environmentName, bool throwConfigurationErrorsException)

Parameters

collection ConnectionStringSettingsCollection

The collection.

unqualifiedKey string

The unqualified key.

environmentName string

Name of the environment.

throwConfigurationErrorsException bool

if set to true throw configuration errors exception.

Returns

string

GetConnectionNameFromEnvironment(ConnectionStringSettingsCollection?, string?, string?, string?)

Gets the connection name from environment.

public static string? GetConnectionNameFromEnvironment(this ConnectionStringSettingsCollection? collection, string? unqualifiedKey, string? environmentName, string? delimiter)

Parameters

collection ConnectionStringSettingsCollection

The collection.

unqualifiedKey string

The unqualified key.

environmentName string

Name of the environment.

delimiter string

The delimiter.

Returns

string

GetConnectionNameFromEnvironment(ConnectionStringSettingsCollection?, string?, string?, string?, bool)

Gets the connection name from environment.

public static string? GetConnectionNameFromEnvironment(this ConnectionStringSettingsCollection? collection, string? unqualifiedKey, string? environmentName, string? delimiter, bool throwConfigurationErrorsException)

Parameters

collection ConnectionStringSettingsCollection

The collection.

unqualifiedKey string

The unqualified key.

environmentName string

Name of the environment.

delimiter string

The delimiter.

throwConfigurationErrorsException bool

if set to true throw configuration errors exception.

Returns

string

GetConnectionStringSettings(ConnectionStringSettingsCollection?, string?)

Gets the connection string settings.

public static ConnectionStringSettings? GetConnectionStringSettings(this ConnectionStringSettingsCollection? collection, string? connectionName)

Parameters

collection ConnectionStringSettingsCollection

The collection.

connectionName string

Name of the connection.

Returns

ConnectionStringSettings

GetConnectionStringSettings(ConnectionStringSettingsCollection?, string?, bool)

Gets the connection string settings.

public static ConnectionStringSettings? GetConnectionStringSettings(this ConnectionStringSettingsCollection? collection, string? connectionName, bool throwConfigurationErrorsException)

Parameters

collection ConnectionStringSettingsCollection

The collection.

connectionName string

Name of the connection.

throwConfigurationErrorsException bool

if set to true throw configuration errors exception.

Returns

ConnectionStringSettings

GetEnvironmentName(KeyValueConfigurationCollection?)

Gets the name of the conventional deployment environment.

public static string? GetEnvironmentName(this KeyValueConfigurationCollection? settings)

Parameters

settings KeyValueConfigurationCollection

The settings.

Returns

string

GetEnvironmentName(KeyValueConfigurationCollection?, string?)

Gets the name of the conventional deployment environment.

public static string? GetEnvironmentName(this KeyValueConfigurationCollection? settings, string? environmentKey)

Parameters

settings KeyValueConfigurationCollection

The settings.

environmentKey string

The environment key.

Returns

string

GetEnvironmentName(KeyValueConfigurationCollection?, string?, string)

Gets the name of the conventional deployment environment.

public static string? GetEnvironmentName(this KeyValueConfigurationCollection? settings, string? environmentKey, string defaultEnvironmentName)

Parameters

settings KeyValueConfigurationCollection

The settings.

environmentKey string

The environment key.

defaultEnvironmentName string

Default name of the environment.

Returns

string

GetEnvironmentName(KeyValueConfigurationCollection?, string?, string, bool)

Gets the name of the conventional deployment environment.

public static string? GetEnvironmentName(this KeyValueConfigurationCollection? settings, string? environmentKey, string defaultEnvironmentName, bool throwConfigurationErrorsException)

Parameters

settings KeyValueConfigurationCollection

The settings.

environmentKey string

The environment key.

defaultEnvironmentName string

Default name of the environment.

throwConfigurationErrorsException bool

if set to true throw configuration errors exception.

Returns

string

GetKeyWithEnvironmentName(KeyValueConfigurationCollection?, string?, string?)

Gets the name of the key with environment.

public static string? GetKeyWithEnvironmentName(this KeyValueConfigurationCollection? settings, string? unqualifiedKey, string? environmentName)

Parameters

settings KeyValueConfigurationCollection

The settings.

unqualifiedKey string

The unqualified key.

environmentName string

Name of the environment.

Returns

string

GetKeyWithEnvironmentName(KeyValueConfigurationCollection?, string?, string?, bool)

Gets the name of the key with environment.

public static string? GetKeyWithEnvironmentName(this KeyValueConfigurationCollection? settings, string? unqualifiedKey, string? environmentName, bool throwConfigurationErrorsException)

Parameters

settings KeyValueConfigurationCollection

The settings.

unqualifiedKey string

The unqualified key.

environmentName string

Name of the environment.

throwConfigurationErrorsException bool

if set to true [throw configuration errors exception].

Returns

string

GetKeyWithEnvironmentName(KeyValueConfigurationCollection?, string?, string?, string?)

Gets the key with environment name.

public static string? GetKeyWithEnvironmentName(this KeyValueConfigurationCollection? settings, string? unqualifiedKey, string? environmentName, string? delimiter)

Parameters

settings KeyValueConfigurationCollection

The settings.

unqualifiedKey string

The unqualified key.

environmentName string

Name of the environment.

delimiter string

The delimiter.

Returns

string

GetKeyWithEnvironmentName(KeyValueConfigurationCollection?, string?, string?, string?, bool)

Gets the key with environment name.

public static string? GetKeyWithEnvironmentName(this KeyValueConfigurationCollection? settings, string? unqualifiedKey, string? environmentName, string? delimiter, bool throwConfigurationErrorsException)

Parameters

settings KeyValueConfigurationCollection

The settings.

unqualifiedKey string

The unqualified key.

environmentName string

Name of the environment.

delimiter string

The delimiter.

throwConfigurationErrorsException bool

if set to true throw configuration errors exception.

Returns

string

GetSetting(KeyValueConfigurationCollection?, string?)

Gets the setting from the current KeyValueConfigurationCollection.

public static string? GetSetting(this KeyValueConfigurationCollection? settings, string? key)

Parameters

settings KeyValueConfigurationCollection

The settings.

key string

The key.

Returns

string

GetSetting(KeyValueConfigurationCollection?, string?, bool)

Gets the setting from the current KeyValueConfigurationCollection.

public static string? GetSetting(this KeyValueConfigurationCollection? settings, string? key, bool throwConfigurationErrorsException)

Parameters

settings KeyValueConfigurationCollection

The settings.

key string

The key.

throwConfigurationErrorsException bool

if set to true throw configuration errors exception.

Returns

string

GetSetting(KeyValueConfigurationCollection?, string?, bool, Func<string?, string>?)

Gets the setting from the current KeyValueConfigurationCollection.

public static string? GetSetting(this KeyValueConfigurationCollection? settings, string? key, bool throwConfigurationErrorsException, Func<string?, string>? settingModifier)

Parameters

settings KeyValueConfigurationCollection

The settings.

key string

The key.

throwConfigurationErrorsException bool

if set to true throw configuration errors exception.

settingModifier Func<string, string>

The setting modifier.

Returns

string

ToAppSettings(XDocument?)

Converts the external configuration file to the application settings KeyValueConfigurationCollection.

public static KeyValueConfigurationCollection? ToAppSettings(this XDocument? externalConfigurationDoc)

Parameters

externalConfigurationDoc XDocument

The external configuration document.

Returns

KeyValueConfigurationCollection

ToConnectionStringSettingsCollection(XDocument?)

Converts the external configuration file to the application settings ConnectionStringSettingsCollection.

public static ConnectionStringSettingsCollection? ToConnectionStringSettingsCollection(this XDocument? externalConfigurationDoc)

Parameters

externalConfigurationDoc XDocument

The external configuration document.

Returns

ConnectionStringSettingsCollection

WithAppSettings(KeyValueConfigurationCollection?, XDocument?)

Returns KeyValueConfigurationCollection with the application settings of the specified external configuration XDocument.

public static KeyValueConfigurationCollection? WithAppSettings(this KeyValueConfigurationCollection? settings, XDocument? externalConfigurationDoc)

Parameters

settings KeyValueConfigurationCollection

The settings.

externalConfigurationDoc XDocument

The external configuration document.

Returns

KeyValueConfigurationCollection

WithConnectionStringSettingsCollection(ConnectionStringSettingsCollection?, XDocument?)

Returns ConnectionStringSettingsCollection with the application settings of the specified external configuration XDocument.

public static ConnectionStringSettingsCollection? WithConnectionStringSettingsCollection(this ConnectionStringSettingsCollection? collection, XDocument? externalConfigurationDoc)

Parameters

collection ConnectionStringSettingsCollection

The collection.

externalConfigurationDoc XDocument

The external configuration document.

Returns

ConnectionStringSettingsCollection