DesignForms
TStructure Class Reference

Structured variable More...

Inherits DynamicObject, IReflection, IStructure, and IDictionary.

Public Member Functions

 TStructure (string Key1, object Value1, string Key2, object Value2, string KeyN, object ValueN)
 Constructor of the structure.
Number of Key-Value pairs is unlimited. More...
 
void AddChild (TStructure NewChild)
 Add structured subnode to the structure More...
 
void AddChild (string Key, object Value)
 Add new subnode to the structure More...
 
void Clear ()
 Clears the content of the structure. More...
 
TStructure CreatePath (string Path)
 Creates complete sub-structure defined by the given path More...
 
bool ContainsKey (string Key)
 Determines whether the structure contains an element with the specified key. More...
 
bool Contains (string Key)
 Returns true, if the given Key exists. The MUST NOT be structured path. If you need to detect if the path exists, use function "ContainsPath" More...
 
bool ContainsPath (string Path)
 Returns true, if the given Path exists. Path can be structured. More...
 
bool TryGetValue (string Key, out object Value)
 Gets the value associated with the specified key. More...
 
bool TryGetValueFromPath (string Path, out object Value)
 Gets the value associated with the specified key. More...
 
void Remove (string Key)
 Removes the value with the specified key from the structure. More...
 
void Set (string Path, object Value)
 Sets the value of subnode. Function creates the subnode, if not exists More...
 
object Get (string Path)
 Returns the value of the subnode at given path More...
 
object Get (string Path, object DefaultValue)
 Returns the value of the subnode at given path. If the path doesn't exists, returns specified default value. More...
 
override string ToString ()
 Convert the Structure to the string. Nested structures are not expanded. More...
 
string ToString (double MaxLevel)
 Convert the Structure to the string with given level of expansion More...
 
TStructure Clone ()
 Returns deep copy of the structure. Warning: This function will stop the program run, if the structure contains circular reference! More...
 

Properties

int Count [get]
 Property 'Count' is not implemented for type 'Structure'. you need number of Key-Value pairs, use Structure.Keys.Count More...
 
ICollection Keys [get]
 Gets a collection containing the keys in the structure More...
 
ICollection Values [get]
 Gets a collection containing the values in the structure More...
 

Detailed Description

Structured variable

Constructor & Destructor Documentation

TStructure ( string  Key1,
object  Value1,
string  Key2,
object  Value2,
string  KeyN,
object  ValueN 
)

Constructor of the structure.
Number of Key-Value pairs is unlimited.

Parameters
Key1Key of the fist value
Value1First value
Key2Key of the second value
Value2Second value
KeyNKey of the Nth value
ValueNNth value

Member Function Documentation

void AddChild ( TStructure  NewChild)

Add structured subnode to the structure

Parameters
NewChildStructured subnode
void AddChild ( string  Key,
object  Value 
)

Add new subnode to the structure

Parameters
KeyString key (name) of the subnode. This key is used to obtain the value from the structure.
ValueValue of the subnode
void Clear ( )

Clears the content of the structure.

TStructure Clone ( )

Returns deep copy of the structure. Warning: This function will stop the program run, if the structure contains circular reference!

Returns
Deep copy of the structure.
bool Contains ( string  Key)

Returns true, if the given Key exists. The MUST NOT be structured path. If you need to detect if the path exists, use function "ContainsPath"

Parameters
KeyKey to be tested. Key MUST NOT be structured path.
Returns
TRUE if the Key exists, otherwise false
bool ContainsKey ( string  Key)

Determines whether the structure contains an element with the specified key.

Parameters
KeyThe key to locate in the structure
Returns
true if the structure contains an element with the key; otherwise, false.
bool ContainsPath ( string  Path)

Returns true, if the given Path exists. Path can be structured.

Parameters
PathPath to the subnode
Returns
Returns TRUE, if the specified path exists. Otherwise false.
TStructure CreatePath ( string  Path)

Creates complete sub-structure defined by the given path

Parameters
PathPath to be created
Returns
Value saved at given path.
object Get ( string  Path)

Returns the value of the subnode at given path

Parameters
PathComplete path to the subnode
Returns
The value of the subnode at given path
object Get ( string  Path,
object  DefaultValue 
)

Returns the value of the subnode at given path. If the path doesn't exists, returns specified default value.

Parameters
PathComplete path to the subnode
DefaultValueDefault value used if the subnode is not found (path not exitst).
Returns
The value of the subnode at given path, or specified default value.
void Remove ( string  Key)

Removes the value with the specified key from the structure.

Parameters
Key
void Set ( string  Path,
object  Value 
)

Sets the value of subnode. Function creates the subnode, if not exists

Parameters
PathPath of the subnode
ValueValue of the subnode
override string ToString ( )

Convert the Structure to the string. Nested structures are not expanded.

Returns
String representation of the structure
string ToString ( double  MaxLevel)

Convert the Structure to the string with given level of expansion

Parameters
MaxLevelDepth of expanded sub-structures and lists
Returns
bool TryGetValue ( string  Key,
out object  Value 
)

Gets the value associated with the specified key.

Parameters
KeyThe key of the value to get.
ValueWhen this method returns, contains the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.
Returns
TRUE if the structure contains an element with the specified key; otherwise, FALSE.
bool TryGetValueFromPath ( string  Path,
out object  Value 
)

Gets the value associated with the specified key.

Parameters
PathThe path (including '.' and '[]' to the value to get.
ValueWhen this method returns, contains the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.
Returns
TRUE if the structure contains an element with the specified key; otherwise, FALSE.

Property Documentation

int Count
get

Property 'Count' is not implemented for type 'Structure'. you need number of Key-Value pairs, use Structure.Keys.Count

ICollection Keys
get

Gets a collection containing the keys in the structure

ICollection Values
get

Gets a collection containing the values in the structure