Class Configuration
Provides top-level configuration abstraction
Inheritance
System.Object
Configuration
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()
Assembly: Azos.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 |
|
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
m_EmptySectionNode
Declaration
protected ConfigSectionNode m_EmptySectionNode
Field Value
m_Root
Declaration
protected ConfigSectionNode m_Root
Field Value
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
Properties
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> |
|
Application
Gets/sets application transient context. It is NOT serialized. Setting this to null (which is the default value)
returns current Ambient application context
Declaration
public IApplication Application { get; set; }
Property Value
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
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
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
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
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
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
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
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
Declaration
public string Variable_PATH_MOD { get; set; }
Property Value
Type |
Description |
System.String |
|
Variable_START
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
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
Returns
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 Parameters
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()
Declaration
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
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
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
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
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
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
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
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
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
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
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
ToLaconicString(LaconfigWritingOptions)
Serializes configuration tree into Laconic format and returns it as a string
Declaration
public string ToLaconicString(LaconfigWritingOptions options = null)
Parameters
Returns
Type |
Description |
System.String |
|
Implements
System.ICloneable
Extension Methods