Table of Contents

Class DictionaryExtensions

Namespace
Tripous
Assembly
Tripous.dll

A helper class for returning typed values from an IDictionary in a safe manner. It assumes that the FlagName is always a string

public static class DictionaryExtensions
Inheritance
DictionaryExtensions
Inherited Members

Methods

AsBoolean(IDictionary<string, object>, string)

Returns the Value of Key

public static bool AsBoolean(this IDictionary<string, object> Data, string Key)

Parameters

Data IDictionary<string, object>
Key string

Returns

bool

AsBoolean(IDictionary, string)

Returns the Value of FlagName if exists, else false

public static bool AsBoolean(this IDictionary Dictionary, string Key)

Parameters

Dictionary IDictionary
Key string

Returns

bool

AsBoolean(IDictionary, string, bool)

Returns the Value of FlagName if exists, else Default

public static bool AsBoolean(this IDictionary Dictionary, string Key, bool Default)

Parameters

Dictionary IDictionary
Key string
Default bool

Returns

bool

AsDateTime(IDictionary<string, object>, string)

Returns the Value of Key

public static DateTime AsDateTime(this IDictionary<string, object> Data, string Key)

Parameters

Data IDictionary<string, object>
Key string

Returns

DateTime

AsDateTime(IDictionary, string)

Returns the Value of FlagName if exists, else DateTime.Now

public static DateTime AsDateTime(this IDictionary Dictionary, string Key)

Parameters

Dictionary IDictionary
Key string

Returns

DateTime

AsDateTime(IDictionary, string, DateTime)

Returns the Value of FlagName if exists, else Default

public static DateTime AsDateTime(this IDictionary Dictionary, string Key, DateTime Default)

Parameters

Dictionary IDictionary
Key string
Default DateTime

Returns

DateTime

AsFloat(IDictionary<string, object>, string)

Returns the Value of Key

public static double AsFloat(this IDictionary<string, object> Data, string Key)

Parameters

Data IDictionary<string, object>
Key string

Returns

double

AsFloat(IDictionary, string)

Returns the Value of FlagName if exists, else 0

public static double AsFloat(this IDictionary Dictionary, string Key)

Parameters

Dictionary IDictionary
Key string

Returns

double

AsFloat(IDictionary, string, double)

Returns the Value of FlagName if exists, else Default

public static double AsFloat(this IDictionary Dictionary, string Key, double Default)

Parameters

Dictionary IDictionary
Key string
Default double

Returns

double

AsInteger(IDictionary<string, object>, string)

Returns the Value of Key

public static int AsInteger(this IDictionary<string, object> Data, string Key)

Parameters

Data IDictionary<string, object>
Key string

Returns

int

AsInteger(IDictionary, string)

Returns the Value of FlagName if exists, else Default

public static int AsInteger(this IDictionary Dictionary, string Key)

Parameters

Dictionary IDictionary
Key string

Returns

int

AsInteger(IDictionary, string, int)

Returns the Value of FlagName if exists, else Default

public static int AsInteger(this IDictionary Dictionary, string Key, int Default)

Parameters

Dictionary IDictionary
Key string
Default int

Returns

int

AsObject(IDictionary<string, object>, string)

Returns the Value of Key

public static object AsObject(this IDictionary<string, object> Data, string Key)

Parameters

Data IDictionary<string, object>
Key string

Returns

object

AsObject(IDictionary, string, object)

Returns the Value of FlagName if exists, else Default

public static object AsObject(this IDictionary Dictionary, string Key, object Default)

Parameters

Dictionary IDictionary
Key string
Default object

Returns

object

AsString(IDictionary<string, object>, string)

Returns the Value of Key

public static string AsString(this IDictionary<string, object> Data, string Key)

Parameters

Data IDictionary<string, object>
Key string

Returns

string

AsString(IDictionary, string)

Returns the Value of FlagName if exists, else the empty string

public static string AsString(this IDictionary Dictionary, string Key)

Parameters

Dictionary IDictionary
Key string

Returns

string

AsString(IDictionary, string, string)

Returns the Value of FlagName if exists, else 0

public static string AsString(this IDictionary Dictionary, string Key, string Default)

Parameters

Dictionary IDictionary
Key string
Default string

Returns

string

Assign<TKey, TValue>(IDictionary<TKey, TValue>, IDictionary<TKey, TValue>, bool)

Assigns Dest to Source

public static void Assign<TKey, TValue>(this IDictionary<TKey, TValue> Source, IDictionary<TKey, TValue> Dest, bool ClearSource = true)

Parameters

Source IDictionary<TKey, TValue>
Dest IDictionary<TKey, TValue>
ClearSource bool

Type Parameters

TKey
TValue

DicToText(IDictionary<string, string>)

Converts Dictionary to a text lines, where each line has the format FlagName=Value

public static string DicToText(this IDictionary<string, string> Dictionary)

Parameters

Dictionary IDictionary<string, string>

Returns

string

LoadFromXml(IDictionary<string, string>, XmlNode, string)

Loads Dictionary from ParentNode. See SaveToXml() for a description of the node tree

public static void LoadFromXml(this IDictionary<string, string> Dictionary, XmlNode ParentNode, string ListNodeName)

Parameters

Dictionary IDictionary<string, string>
ParentNode XmlNode
ListNodeName string

SaveToXml(IDictionary<string, string>, XmlNode, string)

Saves Dictionary to ParentNode. A child node with ListNodeName is created to that ParentNode. Then each Dictionary entry becomes a child Node to that ListNodeName Node, with "item" as node name. FlagName and Value of each Dictionary entry are saved as attributes to that item Node.

public static void SaveToXml(this IDictionary<string, string> Dictionary, XmlNode ParentNode, string ListNodeName)

Parameters

Dictionary IDictionary<string, string>
ParentNode XmlNode
ListNodeName string

SaveToXml(IDictionary<string, string>, XmlNode, string, string)

Saves Dictionary to ParentNode. A child node with ListNodeName is created to that ParentNode. Then each Dictionary entry becomes a child Node to that ListNodeName Node, with ItemNodeName. FlagName and Value of each Dictionary entry are saved as attributes to that item Node.

public static void SaveToXml(this IDictionary<string, string> Dictionary, XmlNode ParentNode, string ListNodeName, string ItemNodeName)

Parameters

Dictionary IDictionary<string, string>
ParentNode XmlNode
ListNodeName string
ItemNodeName string

TextToDic(IDictionary<string, string>, string)

Loads Dictionary using Text. Text must be zero or more lines, where each line has the format FlagName=Value

public static void TextToDic(this IDictionary<string, string> Dictionary, string Text)

Parameters

Dictionary IDictionary<string, string>
Text string

ValueOf<T>(IDictionary<string, object>, string, T)

Returns the value of Key if exists and not null, else returns Default.

public static T ValueOf<T>(this IDictionary<string, object> Data, string Key, T Default)

Parameters

Data IDictionary<string, object>
Key string
Default T

Returns

T

Type Parameters

T

ValueOf<T>(Hashtable, string, T)

Returns the value of Key if exists and not null, else returns Default.

public static T ValueOf<T>(this Hashtable Data, string Key, T Default)

Parameters

Data Hashtable
Key string
Default T

Returns

T

Type Parameters

T

ValuesToRow(IDictionary, DataRow)

Passes values from Values to Row.

public static void ValuesToRow(this IDictionary Values, DataRow Row)

Parameters

Values IDictionary
Row DataRow