Show / Hide Table of Contents

Class Configuration

Provides top-level configuration abstraction

Inheritance
System.Object
Configuration
CommandArgsConfiguration
FileConfiguration
MemoryConfiguration
Implements
System.ICloneable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: NFX.Environment
Assembly: NFX.dll
Syntax
[Serializable]
public abstract class Configuration : ICloneable

Constructors

Configuration()

Declaration
protected Configuration()

Fields

CONFIG_INCLUDE_PRAGMA_FILE_ATTR

Declaration
public const string CONFIG_INCLUDE_PRAGMA_FILE_ATTR = "file"
Field Value
Type Description
System.String

CONFIG_INCLUDE_PRAGMA_FS_SECTION

Declaration
public const string CONFIG_INCLUDE_PRAGMA_FS_SECTION = "fs"
Field Value
Type Description
System.String

CONFIG_INCLUDE_PRAGMA_PROVIDER_SECTION

Declaration
public const string CONFIG_INCLUDE_PRAGMA_PROVIDER_SECTION = "provider"
Field Value
Type Description
System.String

CONFIG_INCLUDE_PRAGMA_REQUIRED_ATTR

Declaration
public const string CONFIG_INCLUDE_PRAGMA_REQUIRED_ATTR = "required"
Field Value
Type Description
System.String

CONFIG_INCLUDE_PRAGMA_SESSION_SECTION

Declaration
public const string CONFIG_INCLUDE_PRAGMA_SESSION_SECTION = "session"
Field Value
Type Description
System.String

CONFIG_LACONIC_FORMAT

Declaration
public const string CONFIG_LACONIC_FORMAT = "laconf"
Field Value
Type Description
System.String

CONFIG_NAME_ATTR

Declaration
public const string CONFIG_NAME_ATTR = "name"
Field Value
Type Description
System.String

CONFIG_ORDER_ATTR

Declaration
public const string CONFIG_ORDER_ATTR = "order"
Field Value
Type Description
System.String

DEFAULT_CONFIG_INCLUDE_PRAGMA

Declaration
public const string DEFAULT_CONFIG_INCLUDE_PRAGMA = "_include"
Field Value
Type Description
System.String

DEFAULT_VAR_END

Declaration
public const string DEFAULT_VAR_END = ")"
Field Value
Type Description
System.String

DEFAULT_VAR_ENV_MOD

Declaration
public const string DEFAULT_VAR_ENV_MOD = "~"
Field Value
Type Description
System.String

DEFAULT_VAR_ESCAPE

Declaration
public const string DEFAULT_VAR_ESCAPE = "$(###)"
Field Value
Type Description
System.String

DEFAULT_VAR_MACRO_START

Declaration
public const string DEFAULT_VAR_MACRO_START = "::"
Field Value
Type Description
System.String

DEFAULT_VAR_PATH_MOD

Declaration
public const string DEFAULT_VAR_PATH_MOD = "@"
Field Value
Type Description
System.String

DEFAULT_VAR_START

Declaration
public const string DEFAULT_VAR_START = "$("
Field Value
Type Description
System.String

m_EmptyAttrNode

Declaration
protected ConfigAttrNode m_EmptyAttrNode
Field Value
Type Description
ConfigAttrNode

m_EmptySectionNode

Declaration
protected ConfigSectionNode m_EmptySectionNode
Field Value
Type Description
ConfigSectionNode

m_Root

Declaration
protected ConfigSectionNode m_Root
Field Value
Type Description
ConfigSectionNode

ProcesswideConfigNodeProviderType

Gets/sets global implementor of IConfigNodeProvider that is used by all configurations in this process instance when type is not specified

Declaration
public static Type ProcesswideConfigNodeProviderType
Field Value
Type Description
System.Type

ProcesswideEnvironmentVarResolver

Gets/sets global Environment variable resolver that is used by all configurations in this process instance

Declaration
public static IEnvironmentVariableResolver ProcesswideEnvironmentVarResolver
Field Value
Type Description
IEnvironmentVariableResolver

Properties

AllSupportedFormats

Returns all configuration file formats (file extensions without '.') supported by ProviderLoadFromFile/ProviderLoadFromAnySupportedFormatFile/ProviderLoadFromString

Declaration
public static IEnumerable<string> AllSupportedFormats { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<System.String>

ContentView

Primarily used for debugging - returns the content of the configuration as text in the pretty-printed Laconic format

Declaration
public string ContentView { get; }
Property Value
Type Description
System.String

EmptyAttr

References a special instance of an empty attribute node (one per configuration). Empty nodes are returned by indexers when a real node with specified name does not exist

Declaration
public ConfigAttrNode EmptyAttr { get; }
Property Value
Type Description
ConfigAttrNode

EmptySection

References a special instance of an empty section node (one per configuration). Empty nodes are returned by indexers when a real node with specified name does not exist

Declaration
public ConfigSectionNode EmptySection { get; }
Property Value
Type Description
ConfigSectionNode

EnvironmentVarResolver

References variable resolver. If this property is not set then default Windows environment var resolver is used

Declaration
public IEnvironmentVariableResolver EnvironmentVarResolver { get; set; }
Property Value
Type Description
IEnvironmentVariableResolver

IsReadOnly

Indicates whether configuration is read-only

Declaration
public abstract bool IsReadOnly { get; }
Property Value
Type Description
System.Boolean

MacroRunner

References macro runner. If this property is not set then default macro runner is used

Declaration
public IMacroRunner MacroRunner { get; set; }
Property Value
Type Description
IMacroRunner

MacroRunnerContext

Gets/sets an object passed by the framework into MacroRunner.Run() method. This property is auto-set for classes decorated with [ConfigMacroContext] attribute

Declaration
public object MacroRunnerContext { get; set; }
Property Value
Type Description
System.Object

Root

Accesses root section configuration node

Declaration
public ConfigSectionNode Root { get; }
Property Value
Type Description
ConfigSectionNode

StrictNames

Determines whether exception is thrown when configuration node name contains inappropriate chars for particular configuration type. For example, for XMLConfiguration node names may not have spaces and other separator chars. When StrictNames is false then particular configurations may replace incompatible chars in node names with neutral ones (i.e. "my value"->"my-value" in case of XMLConfiguration).

Declaration
public bool StrictNames { get; set; }
Property Value
Type Description
System.Boolean

Variable_END

Variable end tag

Declaration
public string Variable_END { get; set; }
Property Value
Type Description
System.String

Variable_ENV_MOD

Variable environment modifier

Declaration
public string Variable_ENV_MOD { get; set; }
Property Value
Type Description
System.String

Variable_ESCAPE

Variable escape tag

Declaration
public string Variable_ESCAPE { get; set; }
Property Value
Type Description
System.String

Variable_MACRO_START

Variable get clause modifier

Declaration
public string Variable_MACRO_START { get; }
Property Value
Type Description
System.String

Variable_PATH_MOD

Variable path modifier

Declaration
public string Variable_PATH_MOD { get; set; }
Property Value
Type Description
System.String

Variable_START

Variable start tag

Declaration
public string Variable_START { get; set; }
Property Value
Type Description
System.String

Methods

AdjustNodeName(String)

Override to perform transforms on node names so they become suitable for particular configuration type

Declaration
protected virtual string AdjustNodeName(string name)
Parameters
Type Name Description
System.String name
Returns
Type Description
System.String

CheckAndAdjustNodeName(String)

Checks node name for aptitude for particular configuration type. For example, XML configuration does not allow nodes with spaces or separator chars. When StrictNames is set to true and value is not appropriate then exception is thrown

Declaration
public string CheckAndAdjustNodeName(string name)
Parameters
Type Name Description
System.String name
Returns
Type Description
System.String

Clone()

Implements IClonable by returning new MemoryConfiguration clone

Declaration
public object Clone()
Returns
Type Description
System.Object

Clone(Configuration)

Creates a deep copy of this configuration into newInstance which was allocated externally

Declaration
public Configuration Clone(Configuration newInstance)
Parameters
Type Name Description
Configuration newInstance
Returns
Type Description
Configuration

Clone<T>()

Creates a deep copy of this configuration into new instance of T

Declaration
public Configuration Clone<T>()where T : Configuration, new ()
Returns
Type Description
Configuration
Type Parameters
Name Description
T

Create(String)

Creates new configuration - creates new configuration root with optional name parameter

Declaration
public void Create(string name = "configuration")
Parameters
Type Name Description
System.String name

CreateFromMerge(ConfigSectionNode, ConfigSectionNode, NodeOverrideRules)

Creates new configuration from ordered merge result of two other nodes - base and override which can be from different configurations

Declaration
public void CreateFromMerge(ConfigSectionNode baseNode, ConfigSectionNode overrideNode, NodeOverrideRules rules = null)
Parameters
Type Name Description
ConfigSectionNode baseNode

A base node that data is defaulted from

ConfigSectionNode overrideNode

A node that contains overrides/additions of/to data from base node

NodeOverrideRules rules

Rules to use or default rules will be used in null is passed

CreateFromNode(IConfigSectionNode)

Creates new configuration from other node, which may belong to a different configuration instance

Declaration
public void CreateFromNode(IConfigSectionNode otherNode)
Parameters
Type Name Description
IConfigSectionNode otherNode

A base node that data is defaulted from

Destroy()

Erases all config data

Declaration
public void Destroy()

Include(ConfigSectionNode, ConfigSectionNode)

Completely replaces this node with another node tree, positioning the new tree in the place of local node. Existing node is deleted after this operation completes, in its place child nodes from other node are inserted preserving their existing order. Attributes of other node get merged into parent of existing node

Declaration
public void Include(ConfigSectionNode existing, ConfigSectionNode other)
Parameters
Type Name Description
ConfigSectionNode existing
ConfigSectionNode other

IsSupportedFormat(String)

True when format is supported

Declaration
public static bool IsSupportedFormat(string format)
Parameters
Type Name Description
System.String format
Returns
Type Description
System.Boolean

MakeProviderForFile(String)

Creates new configuration instance of an appropriate provider implementation for the supplied extension format

Declaration
public static FileConfiguration MakeProviderForFile(string fileName)
Parameters
Type Name Description
System.String fileName
Returns
Type Description
FileConfiguration

NewEmptyRoot(String)

Creates a new empty config root based on laconic format

Declaration
public static ConfigSectionNode NewEmptyRoot(string name = null)
Parameters
Type Name Description
System.String name
Returns
Type Description
ConfigSectionNode

ProviderLoadFromAnySupportedFormatFile(String)

Loads the contents of the supplied file name without format extension trying to match any of the supported format extensions. When match is found the file is loaded via an appropriate configuration provider

Declaration
public static Configuration ProviderLoadFromAnySupportedFormatFile(string fileName)
Parameters
Type Name Description
System.String fileName
Returns
Type Description
Configuration
Examples

Given "c:\conf\users" as an input: if "c:\conf\users.xml" exists then it will be opened as XMLConfiguration if "c:\conf\users.laconf" exists then it will be opened as LaconicConfiguration if "c:\conf\users.json" exists then it will be opened as JSONConfiguration and so on... for the rest of supported formats

ProviderLoadFromFile(String)

Loads the contents of the supplied file name in an appropriate configuration provider implementation for the supplied extension format

Declaration
public static Configuration ProviderLoadFromFile(string fileName)
Parameters
Type Name Description
System.String fileName
Returns
Type Description
Configuration

ProviderLoadFromString(String, String, String)

Loads the supplied string content in the specified format, which may be format name like "xml" or "laconfig" with or without extension period

Declaration
public static Configuration ProviderLoadFromString(string content, string format, string fallbackFormat = null)
Parameters
Type Name Description
System.String content
System.String format
System.String fallbackFormat
Returns
Type Description
Configuration

Refresh()

Re-reads configuration from source

Declaration
public virtual void Refresh()

ResolveEnvironmentVar(String, IEnvironmentVariableResolver)

Resolves variable name into its value

Declaration
public string ResolveEnvironmentVar(string name, IEnvironmentVariableResolver resolver = null)
Parameters
Type Name Description
System.String name
IEnvironmentVariableResolver resolver
Returns
Type Description
System.String

RunMacro(IConfigSectionNode, String, String, IConfigSectionNode, IMacroRunner, Object)

Runs macro and returns its value

Declaration
public string RunMacro(IConfigSectionNode node, string inputValue, string macroName, IConfigSectionNode macroParams, IMacroRunner runner = null, object context = null)
Parameters
Type Name Description
IConfigSectionNode node
System.String inputValue
System.String macroName
IConfigSectionNode macroParams
IMacroRunner runner
System.Object context
Returns
Type Description
System.String

Save()

Saves configuration to source

Declaration
public virtual void Save()

ToConfigurationJSONDataMap()

Returns this config as JSON data map suitable for making JSONConfiguration

Declaration
public JSONDataMap ToConfigurationJSONDataMap()
Returns
Type Description
JSONDataMap

ToLaconicFile(String, LaconfigWritingOptions, Encoding)

Serializes configuration tree into Laconic format and writes it into a file

Declaration
public void ToLaconicFile(string filename, LaconfigWritingOptions options = null, Encoding encoding = null)
Parameters
Type Name Description
System.String filename
LaconfigWritingOptions options
System.Text.Encoding encoding

ToLaconicStream(Stream, LaconfigWritingOptions, Encoding)

Serializes configuration tree into Laconic format and writes it into stream

Declaration
public void ToLaconicStream(Stream stream, LaconfigWritingOptions options = null, Encoding encoding = null)
Parameters
Type Name Description
System.IO.Stream stream
LaconfigWritingOptions options
System.Text.Encoding encoding

ToLaconicString(LaconfigWritingOptions)

Serializes configuration tree into Laconic format and returns it as a string

Declaration
public string ToLaconicString(LaconfigWritingOptions options = null)
Parameters
Type Name Description
LaconfigWritingOptions options
Returns
Type Description
System.String

Implements

System.ICloneable

Extension Methods

MiscUtils.NonNull<T>(T, Func<Exception>, String)
ObjectValueConversion.AsString(Object, String, ConvertErrorHandling)
ObjectValueConversion.AsNonNullOrEmptyString(Object)
ObjectValueConversion.AsLaconicConfig(Object, ConfigSectionNode, String, ConvertErrorHandling)
ObjectValueConversion.AsJSONConfig(Object, ConfigSectionNode, String, ConvertErrorHandling)
ObjectValueConversion.AsXMLConfig(Object, ConfigSectionNode, ConvertErrorHandling)
ObjectValueConversion.AsChar(Object, Char, ConvertErrorHandling)
ObjectValueConversion.AsNullableChar(Object, Nullable<Char>, ConvertErrorHandling)
ObjectValueConversion.AsByte(Object, Byte, ConvertErrorHandling)
ObjectValueConversion.AsNullableByte(Object, Nullable<Byte>, ConvertErrorHandling)
ObjectValueConversion.AsSByte(Object, SByte, ConvertErrorHandling)
ObjectValueConversion.AsNullableSByte(Object, Nullable<SByte>, ConvertErrorHandling)
ObjectValueConversion.AsShort(Object, Int16, ConvertErrorHandling)
ObjectValueConversion.AsNullableShort(Object, Nullable<Int16>, ConvertErrorHandling)
ObjectValueConversion.AsUShort(Object, UInt16, ConvertErrorHandling)
ObjectValueConversion.AsNullableUShort(Object, Nullable<UInt16>, ConvertErrorHandling)
ObjectValueConversion.AsInt(Object, Int32, ConvertErrorHandling)
ObjectValueConversion.AsNullableInt(Object, Nullable<Int32>, ConvertErrorHandling)
ObjectValueConversion.AsUInt(Object, UInt32, ConvertErrorHandling)
ObjectValueConversion.AsNullableUInt(Object, Nullable<UInt32>, ConvertErrorHandling)
ObjectValueConversion.AsLong(Object, Int64, ConvertErrorHandling)
ObjectValueConversion.AsNullableLong(Object, Nullable<Int64>, ConvertErrorHandling)
ObjectValueConversion.AsULong(Object, UInt64, ConvertErrorHandling)
ObjectValueConversion.AsNullableULong(Object, Nullable<UInt64>, ConvertErrorHandling)
ObjectValueConversion.AsDouble(Object, Double, ConvertErrorHandling)
ObjectValueConversion.AsNullableDouble(Object, Nullable<Double>, ConvertErrorHandling)
ObjectValueConversion.AsFloat(Object, Single, ConvertErrorHandling)
ObjectValueConversion.AsNullableFloat(Object, Nullable<Single>, ConvertErrorHandling)
ObjectValueConversion.AsDecimal(Object, Decimal, ConvertErrorHandling)
ObjectValueConversion.AsNullableDecimal(Object, Nullable<Decimal>, ConvertErrorHandling)
ObjectValueConversion.AsBool(Object, Boolean, ConvertErrorHandling)
ObjectValueConversion.AsNullableBool(Object, Nullable<Boolean>, ConvertErrorHandling)
ObjectValueConversion.AsGUID(Object, Guid, ConvertErrorHandling)
ObjectValueConversion.AsNullableGUID(Object, Nullable<Guid>, ConvertErrorHandling)
ObjectValueConversion.AsDateTime(Object)
ObjectValueConversion.AsDateTime(Object, DateTime, ConvertErrorHandling)
ObjectValueConversion.AsNullableDateTime(Object, Nullable<DateTime>, ConvertErrorHandling)
ObjectValueConversion.AsGDID(Object)
ObjectValueConversion.AsGDID(Object, GDID, ConvertErrorHandling)
ObjectValueConversion.AsNullableGDID(Object, Nullable<GDID>, ConvertErrorHandling)
ObjectValueConversion.AsGDIDSymbol(Object)
ObjectValueConversion.AsGDIDSymbol(Object, GDIDSymbol, ConvertErrorHandling)
ObjectValueConversion.AsNullableGDIDSymbol(Object, Nullable<GDIDSymbol>, ConvertErrorHandling)
ObjectValueConversion.AsTimeSpan(Object)
ObjectValueConversion.AsTimeSpan(Object, TimeSpan, ConvertErrorHandling)
ObjectValueConversion.AsNullableTimeSpan(Object, Nullable<TimeSpan>, ConvertErrorHandling)
ObjectValueConversion.AsEnum<TEnum>(Object, TEnum, ConvertErrorHandling)
ObjectValueConversion.AsNullableEnum<TEnum>(Object, Nullable<TEnum>, ConvertErrorHandling)
ObjectValueConversion.AsUri(Object, Uri, ConvertErrorHandling)
JSONExtensions.ToJSON(Object, JSONWritingOptions)
JSONExtensions.ToJSON(Object, TextWriter, JSONWritingOptions)
JSONExtensions.ToJSON(Object, Stream, JSONWritingOptions, Encoding)
ErlObject.ToErlObject(Object)
ErlObject.ToErlObject(Object, ErlTypeOrder, Boolean)
Back to top Copyright © 2006-2018 Agnicore Inc
Generated by DocFX