Legend

Class
Struct
Enum
Interface
Delegate
Constructor
Method
Property
Event
Field

Namespace: RT.KitchenSink.Collections

Assembly: RT.Util.Legacy

Enables easy manipulation of simple hierarchical sets of values. Targets specifically the use of XML for storing application settings.

Examples:

RVariant v;
v = 3;                   // now stores the integer "3"
v = "hi there";          // now stores the string
v = DateTime.Now();      // stores current time

string s = v;            // s holds datetime in ISO, e.g. "2008-03-13 19:20:14.1230000Z"

v = new RVariant();      // v can become anything at the moment, known as Stub
v["form1"]["top"] = 20;  // v becomes a Dict, holding another dict, holding 20.
v["columns"][4] = "hi";  // v["columns"] holds a list: 0..3 are all Stubs, while
                         // item 4 holds "hi" and has path "columns[4]"

v["form2"] = v["form1"]; // deep copying

int i = v["form3"]["top"].OrDefaultTo(47);
                         // since form3/top does not exist, returns 47.
                         // but i = v["form3"]["top"]; throws an RVariantConvertException.

RVariant.ToXml(v, "settings").Save("settings.xml");
                         // save to an XML file

Properties that aid debugging:

v.FullPath  - the path to the given node in its hierarchy, e.g. "form2/top".
v.Kind      - one of the possible variant kinds: Stub, List, Dict, Value.
v.Value     - for Value variants, returns the value stored.
Indicates that there was an error while attempting to convert a Value kind variant from one type to another. E.g. converting "hi" to int.
All RVariant exceptions derive from this one.
Determines what kind of an RVariant we're dealing with. See documentation for individual items.
Indicates that a variant was not found where expected. This is only thrown from the .OrNotFound series of methods.
Indicates that RVariant encountered an error while converting XML to variant.