Click here to Skip to main content
15,881,204 members
Articles / Programming Languages / XML

TreeConfiguration - configuration made as simple as it gets (or sets)

Rate me:
Please Sign up or sign in to vote.
4.66/5 (44 votes)
2 Nov 200514 min read 83.4K   724   67  
Manage configuration data with a few lines of code. Very few.
<?xml version="1.0"?>
<doc>
	<members>
		<!-- ConfigurationNode class -->
		<member name="T:ConfigurationNode">
			<summary>Represents a single node in the configuration hierarchy.</summary>
			<remarks>
				<see cref="ConfigurationNode"/> is identified by its name. It can contain zero or 
				more <see cref="ConfigurationNode"/> subnodes and zero or more key/value pairs.
			</remarks>
		</member>
		<!-- Constructors -->
		<member name="M:ConfigurationNode">
			<summary>Creates a new <see cref="ConfigurationNode"/> instance.</summary>
			<param name="name">Node name.</param>
		</member>
		<!-- Properties -->
		<member name="P:Name">
			<summary>Gets or sets the node name.</summary>
			<value>Accesses the value of the <c>_name</c> data member.</value>
		</member>
		<member name="P:Item">
			<summary>Gets or sets the value of the specified key.</summary>
			<value>Concrete value as an <c>object</c> instance.</value>
			<remarks>Get: if the key is not found, <c>null</c> value is returned.</remarks>
			<seealso cref="Nodes" />
			<seealso cref="Keys" />			
			<seealso cref="Values" />			
		</member>
		<member name="P:Nodes">
			<summary>Exposes node's subnodes collection through the <see cref="System.Collections.ICollection"/> interface.</summary>
			<value>
			Accesses the underlying <c>_childNodes</c> member (a <see cref="System.Collections.Specialized.HybridDictionary"/>).
			</value>
			<seealso cref="Keys" />			
			<seealso cref="Values" />			
		</member>
		<member name="P:Keys">
			<summary>Exposes node's keys collection through the <see cref="System.Collections.ICollection"/> interface</summary>
			<value>
			Accesses the underlying <c>_keyValues</c> member (a <see cref="System.Collections.Specialized.HybridDictionary"/>), 
			directly exposing its <see cref="System.Collections.Specialized.HybridDictionary.Keys" /> property.
			</value>
			<remark>The order of keys is not guaranteed, but it always matches the order of values returned through <see cref="Values"/> property.</remark>
			<seealso cref="Nodes" />
			<seealso cref="Values" />			
		</member>
		<member name="P:Values">
			<summary>Exposes node's values collection through the <see cref="System.Collections.ICollection"/> interface.</summary>
			<value>
			Accesses the underlying <c>_keyValues</c> member (a <see cref="System.Collections.Specialized.HybridDictionary"/>), 
			directly exposing its <see cref="System.Collections.Specialized.HybridDictionary.Values" /> property.
			</value>
			<remark>
			The order of values is not guaranteed, but it always matches the order of keys returned 
			through <see cref="Keys"/> property.
			</remark>
			<seealso cref="Nodes" />
			<seealso cref="Keys" />			
		</member>
		<member name="P:Culture">
			<summary>Gets or sets the name of the <see cref="System.Globalization.CultureInfo"/> culture to be used in type conversion.</summary>
			<value>
			Accesses the underlying <c>_culture</c> member.
			</value>
			<remark>
			A culture specified for a node applies to all its child nodes (and key/value pairs), unless a child node
			overrides it. If specified for a root node, a culture applies on the whole configuration.
			If no culture name is specified (default), <see cref="System.Globalization.CultureInfo.CurrentCulture"/> will be used.  
			</remark>
			<seealso cref="System.Globalization.CultureInfo" />
		</member>		
		<member name="P:HasSubNodes">
			<summary>Gets a value indicating whether this <see cref="ConfigurationNode"/> contains subnodes.</summary>
			<value><c>true</c> if node contains at least one subnode; otherwise, <c>false</c>.</value>
			<seealso cref="HasKeys"/>
			<seealso cref="Empty" />
		</member>
		<member name="P:HasKeys">
			<summary>Gets a value indicating whether this <see cref="ConfigurationNode"/> contains key/value pairs.</summary>
			<value><c>true</c> if node contains at least one key/value pair; otherwise, <c>false</c>.</value>
			<seealso cref="HasSubNodes"/>
			<seealso cref="Empty" />
		</member>
		<member name="P:Empty">
			<summary>Gets a value indicating whether this <see cref="ConfigurationNode"/> is empty.</summary>
			<value><c>true</c> if node is empty (no subnodes and no key/value pairs); otherwise, <c>false</c>.</value>
			<seealso cref="HasSubNodes" />
			<seealso cref="HasKeys"/>
		</member>
		<member name="P:NullNode">
			<summary>Special empty <see cref="ConfigurationNode" /> that represents non-existing or invalid node</summary>
			<value>Accesses the underlying <c>static readonly _nullNode</c> member.</value>
			<remarks>
			Unknown or invalid node is represented by an empty <see cref="ConfigurationNode" /> 
      node (instead of <c>null</c>), in order to handle situations when <c>foreach</c> loop is used with 
      a non-existing node.
      </remarks>
		</member>
		<!-- Regular methods -->
		<member name="M:FindSubNode">
			<summary>Finds the subnode.</summary>
			<param name="path">Path to node.</param>
			<returns>Specified node or <see cref="NullNode"/> if the node is not found.</returns>
			<seealso cref="CreateSubNode" />
			<seealso cref="RemoveSubNode" />
		</member>
		<member name="M:CreateSubNode">
			<summary>Creates a subnode using the name of the current path segment.</summary>
			<param name="path">Full path.</param>
			<returns>Newly created node or the existing node</returns>
			<remarks>
			<para>Current path segment must exist.</para>
			<para>After creating a subnode, the current path segment in <c>path</c> is advanced to the next one. The same <c>path</c> argument
			is then passed to a newly created subnode to create its own subnode and so on, thus creating all nodes along the specified path.</para>
			</remarks>
			<exception cref="System.SystemException.NotSupportedException">If the current path segment is an empty string.</exception> 						
			<seealso cref="FindSubNode" />
			<seealso cref="RemoveSubNode" />
		</member>
		<member name="M:RemoveSubNode">
			<summary>Removes the specified subnode.</summary>
			<param name="subNode">Path to subnode to remove.</param>
			<seealso cref="FindSubNode" />
			<seealso cref="CreateSubNode" />
			<seealso cref="RemoveKey" />
			<seealso cref="Clear" />
		</member>
		<member name="M:RemoveKey">
			<summary>Removes the specified key/value pair.</summary>
			<param name="key">Key to remove.</param>
			<seealso cref="RemoveSubNode" />
			<seealso cref="Clear" />			
		</member>
		<member name="M:Clear">
			<summary>Removes all subnodes and key/value pairs.</summary>
			<seealso cref="RemoveSubNode" />
			<seealso cref="RemoveKey" />
		</member>
	</members>
</doc>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
France France
Vladimir Klisic is a half-human, half-software development engineer, currently working for Trema Laboratories in southeastern France (Sophia-Antipolis).

Comments and Discussions