Class ConfigSectionNode
Represents configuration section node. This class is thread safe
Inheritance
System.Object
ConfigSectionNode
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)
Assembly: Azos.dll
Syntax
[Serializable]
public sealed class ConfigSectionNode : ConfigNode, IConfigSectionNode, IConfigNode, INamed
Properties
AttrCount
Returns number of child attribute nodes
Declaration
public int AttrCount { get; }
Property Value
Type |
Description |
System.Int32 |
|
Attributes
Enumerates all attribute nodes
Declaration
public IEnumerable<ConfigAttrNode> Attributes { get; }
Property Value
Type |
Description |
System.Collections.Generic.IEnumerable<ConfigAttrNode> |
|
ChildCount
Returns number of child section nodes
Declaration
public int ChildCount { get; }
Property Value
Type |
Description |
System.Int32 |
|
Children
Enumerates all child nodes
Declaration
public IEnumerable<ConfigSectionNode> Children { get; }
Property Value
HasAttributes
Indicates whether this node has any associated attributes
Declaration
public bool HasAttributes { get; }
Property Value
Type |
Description |
System.Boolean |
|
HasChildren
Indicates whether this node has any child section nodes
Declaration
public bool HasChildren { get; }
Property Value
Type |
Description |
System.Boolean |
|
Item[Int32]
Retrieves section node by index or empty node instance if section node with such index could not be found
Declaration
public ConfigSectionNode this[int idx] { get; }
Parameters
Type |
Name |
Description |
System.Int32 |
idx |
|
Property Value
Item[String[]]
Retrieves section node by names, from left to right until existing node is found.
If no existing node could be found then empty node instance is returned
Declaration
public ConfigSectionNode this[params string[] names] { get; }
Parameters
Type |
Name |
Description |
System.String[] |
names |
|
Property Value
Modified
Indicates whether this or any child nodes or attributes were modified
Declaration
public override bool Modified { get; }
Property Value
Type |
Description |
System.Boolean |
|
Overrides
Methods
AddAttributeNode(String)
Declaration
public ConfigAttrNode AddAttributeNode(string name)
Parameters
Type |
Name |
Description |
System.String |
name |
|
Returns
AddAttributeNode(String, Object)
Declaration
public ConfigAttrNode AddAttributeNode(string name, object value)
Parameters
Type |
Name |
Description |
System.String |
name |
|
System.Object |
value |
|
Returns
AddAttributeNode(String, String)
Declaration
public ConfigAttrNode AddAttributeNode(string name, string value)
Parameters
Type |
Name |
Description |
System.String |
name |
|
System.String |
value |
|
Returns
AddChildNode(IConfigSectionNode)
Adds a new child node into this one deeply cloning nodes data from some other node which may belong to a different conf instance
Declaration
public ConfigSectionNode AddChildNode(IConfigSectionNode clone)
Parameters
Returns
AddChildNode(String)
Declaration
public ConfigSectionNode AddChildNode(string name)
Parameters
Type |
Name |
Description |
System.String |
name |
|
Returns
AddChildNode(String, Object)
Declaration
public ConfigSectionNode AddChildNode(string name, object value)
Parameters
Type |
Name |
Description |
System.String |
name |
|
System.Object |
value |
|
Returns
AddChildNode(String, String)
Adds a new child section node to this node
Declaration
public ConfigSectionNode AddChildNode(string name, string value)
Parameters
Type |
Name |
Description |
System.String |
name |
|
System.String |
value |
|
Returns
AddChildNodeFromMerge(IConfigSectionNode, IConfigSectionNode, NodeOverrideRules)
Adds a new section node to this configuration which is an ordered merge result of two other nodes - base and override.
Declaration
public ConfigSectionNode AddChildNodeFromMerge(IConfigSectionNode baseNode, IConfigSectionNode overrideNode, NodeOverrideRules rules = null)
Parameters
Type |
Name |
Description |
IConfigSectionNode |
baseNode |
A base node that data is defaulted from
|
IConfigSectionNode |
overrideNode |
A node that contains overrides/additions of/to data from base node
|
NodeOverrideRules |
rules |
Rules to use for this merge. Default rules will be used if null is passed
|
Returns
AttrByIndex(Int32)
Returns attribute node by its index or empty attribute if real attribute with such index does not exist
Declaration
public ConfigAttrNode AttrByIndex(int idx)
Parameters
Type |
Name |
Description |
System.Int32 |
idx |
|
Returns
AttrByName(String, Boolean)
Declaration
public ConfigAttrNode AttrByName(string name, bool autoCreate = false)
Parameters
Type |
Name |
Description |
System.String |
name |
|
System.Boolean |
autoCreate |
|
Returns
AttrsToStringMap(Boolean)
Returns attribute values as string map
Declaration
public StringMap AttrsToStringMap(bool verbatim = false)
Parameters
Type |
Name |
Description |
System.Boolean |
verbatim |
|
Returns
Delete()
Deletes this section from its parent
Declaration
public override void Delete()
Overrides
DeleteAllAttributes()
Deletes all attribute nodes from this node
Declaration
public void DeleteAllAttributes()
DeleteAllChildren()
Deletes all child section nodes from this node
Declaration
public void DeleteAllChildren()
EvaluateValueVariables(String)
Evaluates a value string expanding all variables with var-paths relative to this node.
Evaluates configuration variables such as "$(varname)" or "$(@varname)". Varnames are paths
to other config nodes from the same configuration or variable names when prefixed with "". If varname starts with "@" then it gets combined
with input as path string. "" is used to qualify environment vars that get resolved through Configuration.EnvironmentVarResolver
Example: ....add key="Schema.$(/A/B/C/$attr)" value="$(@~HOME)bin\Transforms\"...
Declaration
public string EvaluateValueVariables(string value)
Parameters
Type |
Name |
Description |
System.String |
value |
|
Returns
Type |
Description |
System.String |
|
IsSameNameAttr(IConfigSectionNode)
Returns true when another node has the attribute called 'name' and its value is the same as in this one per case-insensitive culture-neutral comparison
Declaration
public bool IsSameNameAttr(IConfigSectionNode other)
Parameters
Returns
Type |
Description |
System.Boolean |
|
IsSameNameAttr(String)
Returns true when another name is the same as this section "name" attribute per case-insensitive culture-neutral comparison
Declaration
public bool IsSameNameAttr(string other)
Parameters
Type |
Name |
Description |
System.String |
other |
|
Returns
Type |
Description |
System.Boolean |
|
MergeAttributes(IConfigSectionNode, NodeOverrideRules)
Merges attributes from another node into this one. Another node may belong to a different configuration instance
Declaration
public void MergeAttributes(IConfigSectionNode other, NodeOverrideRules rules = null)
Parameters
MergeSections(IConfigSectionNode, NodeOverrideRules)
Merges child sections from another node into this one. Another node may belong to a different configuration instance.
This method ignores override flags and merges nodes regardless
Declaration
public void MergeSections(IConfigSectionNode other, NodeOverrideRules rules = null)
Parameters
Navigate(String)
Navigates the path and return the appropriate node. Example: '!/azos/logger/destination/$file-name'
Declaration
public ConfigNode Navigate(string path)
Parameters
Type |
Name |
Description |
System.String |
path |
If path starts from '!' then exception will be thrown if such a node does not exist;
Use '/' as leading char for root,
'..' for step up,
'$' for attribute name,
[int] for access to subsection or attribute by index,
section[value] for access using value comparison of named section,
section[attr=value] for access using value of sections named attr
Multiple paths may be coalesced using '|' or ';'
|
Returns
Examples
Navigate("/vars/[3]"); Navigate("/tables/table[resident]"); Navigate("/vars/var1/$[2]"); Navigate("/tables/table[name=patient]");
NavigateSection(String)
Navigates the path and return the appropriate section node. Example '!/azos/logger/destination'
Declaration
public ConfigSectionNode NavigateSection(string path)
Parameters
Type |
Name |
Description |
System.String |
path |
If path starts from '!' then exception will be thrown if such a section node does not exist;
Use '/' as leading char for root,
'..' for step up. Multiple paths may be coalesced using '|' or ';'
|
Returns
OverrideBy(IConfigSectionNode, NodeOverrideRules)
Merges another node data by overriding this node's value/attributes/sub nodes according to rules.
Declaration
public bool OverrideBy(IConfigSectionNode other, NodeOverrideRules rules = null)
Parameters
Returns
Type |
Description |
System.Boolean |
True when merge match was made
|
ProcessIncludePragmas(Boolean, String)
Replaces all include pragmas - sections with specified names ('_include' by default), with pointed to configuration file content
as obtained via the call to file system specified in every pragma.
If no FS specified then LocalFileSystem is used. If no file name specified when try to allocate config node provider.
Returns true if include pragmas were found.
Note: this method does not process new include pragmas that may have fetched during this call.
Caution: the file system used in the operation may rely on the App container that may need to be set-up for the call to succeed,
therefore calling this method before app has activated may fail, in such cases a temp app container may be set to get the config file
with processed includes, then the result may be passed to the primary app container ctor.
This call is not logically thread-safe, it must be called from the main thread in the app
Declaration
public bool ProcessIncludePragmas(bool recurse, string includePragma = null)
Parameters
Type |
Name |
Description |
System.Boolean |
recurse |
True to process inner nodes
|
System.String |
includePragma |
Pragma section name, '_include' by default
|
Returns
Type |
Description |
System.Boolean |
True if pragmas were found
|
Examples
azos
{
sectionA{ a=2 b=3}
_include
{
name=secret // '_include' will be replaced by 'secret' with sub-nodes from referenced file
file="/etc/cluster/mysecret.laconf" //would come from local FS
required=false //if file is not found then nothing will be included instead of '_include' which will be just removed
}
_include
{
// '_include' will be replaced by whatever root section content in the referenced file
fs {type="Azos.Web.IO.FileSystem.SVNFileSystem, Azos.Web"}
session { server-url="https://myhost.com/mySvnRepo/trunk/configs" user-name="user1" user-password="******"}
}
}
ReplaceBy(IConfigSectionNode)
Completely replaces this node's attributes, value and children with data from another node
Declaration
public void ReplaceBy(IConfigSectionNode other)
Parameters
ResetModified()
Resets modification of this an all child nodes
Declaration
public override void ResetModified()
Overrides
ToConfigurationJSONDataMap()
Returns this config node as JSON data map suitable for making JSONConfiguration.
Contrast with ToJSONDataMap
Declaration
public JSONDataMap ToConfigurationJSONDataMap()
Returns
ToJSONDataMap()
Converts this ConfigSectionNode to JSONDataMap. Contrast with ToConfigurationJSONDataMap
Be careful: that this operation can "lose" data from ConfigSectionNode.
In other words some ConfigSectionNode information can not be reflected in corresponding JSONDataMap, for example
this method overwrites duplicate key names and does not support section values
Declaration
public JSONDataMap ToJSONDataMap()
Returns
ToJSONString(JSONWritingOptions)
Serializes configuration tree rooted at this node into JSON configuration format and returns it as a string
Declaration
public string ToJSONString(JSONWritingOptions options = null)
Parameters
Returns
Type |
Description |
System.String |
|
ToLaconicString(LaconfigWritingOptions)
Serializes configuration tree rooted at this node into Laconic format and returns it as a string
Declaration
public string ToLaconicString(LaconfigWritingOptions options = null)
Parameters
Returns
Type |
Description |
System.String |
|
ToXmlDoc(String, String)
Serializes configuration tree as XML
Declaration
public XmlDocument ToXmlDoc(string xsl = null, string encoding = null)
Parameters
Type |
Name |
Description |
System.String |
xsl |
|
System.String |
encoding |
|
Returns
Type |
Description |
System.Xml.XmlDocument |
|
ToXmlString(String)
Serializes configuration tree as XML string with optional link to xsl file
Declaration
public string ToXmlString(string xsl = null)
Parameters
Type |
Name |
Description |
System.String |
xsl |
|
Returns
Type |
Description |
System.String |
|
Explicit Interface Implementations
IConfigSectionNode.AttrByIndex(Int32)
Declaration
IConfigAttrNode IConfigSectionNode.AttrByIndex(int idx)
Parameters
Type |
Name |
Description |
System.Int32 |
idx |
|
Returns
IConfigSectionNode.AttrByName(String, Boolean)
Declaration
IConfigAttrNode IConfigSectionNode.AttrByName(string name, bool autoCreate)
Parameters
Type |
Name |
Description |
System.String |
name |
|
System.Boolean |
autoCreate |
|
Returns
IConfigSectionNode.Attributes
Declaration
IEnumerable<IConfigAttrNode> IConfigSectionNode.Attributes { get; }
Returns
IConfigSectionNode.Children
Declaration
IEnumerable<IConfigSectionNode> IConfigSectionNode.Children { get; }
Returns
IConfigSectionNode.Item[Int32]
Declaration
IConfigSectionNode IConfigSectionNode.this[int idx] { get; }
Parameters
Type |
Name |
Description |
System.Int32 |
idx |
|
Returns
IConfigSectionNode.Item[String[]]
Declaration
IConfigSectionNode IConfigSectionNode.this[params string[] names] { get; }
Parameters
Type |
Name |
Description |
System.String[] |
names |
|
Returns
IConfigSectionNode.Navigate(String)
Declaration
IConfigNode IConfigSectionNode.Navigate(string path)
Parameters
Type |
Name |
Description |
System.String |
path |
|
Returns
IConfigSectionNode.NavigateSection(String)
Declaration
IConfigSectionNode IConfigSectionNode.NavigateSection(string path)
Parameters
Type |
Name |
Description |
System.String |
path |
|
Returns
Implements
Extension Methods