Array nodes are containers used to represent sequences, such as JSON arrays. Each array node contains an ordered list of child nodes. There is no limit to nesting: arrays can contain other arrays and objects. Elements of an array are not required to have names.
Array nodes are typically mapped to ordered collections during binding.
roperty
Description
Name
Value
Children
Returns an ordered sequence of child nodes.
ChildrenCount
Returns the number of elements in the Children
sequence.
this[name]
Two array nodes are considered equal if their Children
sequences are equal elementwise and their names match up to differences in case.
Required if nested in an , optional otherwise.
Always returns null
. Only can have values.
Always returns null
. Arrays cannot be navigated with .
Value nodes are key-value pairs with optional keys. They cannot have child nodes and thus are always the leaves of settings node trees. Standalone values are rare: most of the time value nodes can be found inside objects or arrays.
Value nodes are typically mapped to primitive types during binding.
Property
Description
Name
Value
Useful payload. The value of a object field or array element. Can be null.
Children
Always returns an empty sequence.
this[name]
Always returns null
.
Two value nodes are considered equal if their values match exactly and their names match up to differences in case.
Object nodes are containers used to represent objects with named fields/properties. Each object node contains a map of child nodes with their names as keys. There is no limit to nesting: objects can contain other objects and arrays. Elements of an object are required to have non-null names.
Object nodes are typically mapped to arbitrary classes and structs during binding.
roperty
Description
Name
Value
Children
Returns an unordered sequence of child nodes.
ChildrenCount
Returns the number of elements in the Children
sequence.
this[name]
Returns a child node with given name or null
if such a node does not exist.
Two object nodes are considered equal if their Children
sequences are equivalent (contain equal elements but may present different order) and their names match up to differences in case.
Required if nested in an , optional otherwise.
Required if nested in an , optional otherwise.
Always returns null
. Only can have values.
Settings nodes are the intermediate representation of configuration data and one of the core concepts of the library. Their main purpose is to abstract away various configuration formats (JSON, XML, etc.) so that binding to model classes can be implemented once without regard to the nature of configuration sources being used.
A settings node is a tree with string keys and string values in its leaf nodes.
Configuration sources produce settings nodes as their primary artifacts.
Binding is the process of converting a settings node to an arbitrary .NET object.
Settings nodes are implemented in the abstractions module.
Settings nodes are immutable objects.
Despite being a somewhat internal API used directly only in a handful of advanced scenarios, settings nodes are crucial for a solid understanding of how configuration data translates to objects in C# code via different node types and scoping.
Implementation of a custom configuration source;
Implementation of a custom model binder;
Transformation of configuration sources
There are three types of nodes:
Value nodes, used to hold data;
Array nodes, used to represent sequences;
Object nodes, used to represent objects with named properties.
Users are not expected to implement custom node types.
Null
node instances represent absence of settings (e.g. a configuration file that does not exist).
All node types implement the ISettingsNode interface and have following properties:
Property
Type
Description
Name
string
Node name. Case-insensitive.
Value
string
Children
IEnumerable<ISettingsNode>
this[name]
ISettingsNode
All nodes also implement a merge operation.
All node types implement a JSON-like ToString()
method. Its result may look like this for a sample object node with two nested value nodes:
This representation is extensively used on the rest of the pages.
Node value. Only present in .
Sequence of child nodes in containers: and .
Name-based indexer used to navigate (see ).