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
DataIDictionary<string, object>Keystring
Returns
AsBoolean(IDictionary, string)
Returns the Value of FlagName if exists, else false
public static bool AsBoolean(this IDictionary Dictionary, string Key)
Parameters
DictionaryIDictionaryKeystring
Returns
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
DictionaryIDictionaryKeystringDefaultbool
Returns
AsDateTime(IDictionary<string, object>, string)
Returns the Value of Key
public static DateTime AsDateTime(this IDictionary<string, object> Data, string Key)
Parameters
DataIDictionary<string, object>Keystring
Returns
AsDateTime(IDictionary, string)
Returns the Value of FlagName if exists, else DateTime.Now
public static DateTime AsDateTime(this IDictionary Dictionary, string Key)
Parameters
DictionaryIDictionaryKeystring
Returns
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
DictionaryIDictionaryKeystringDefaultDateTime
Returns
AsFloat(IDictionary<string, object>, string)
Returns the Value of Key
public static double AsFloat(this IDictionary<string, object> Data, string Key)
Parameters
DataIDictionary<string, object>Keystring
Returns
AsFloat(IDictionary, string)
Returns the Value of FlagName if exists, else 0
public static double AsFloat(this IDictionary Dictionary, string Key)
Parameters
DictionaryIDictionaryKeystring
Returns
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
DictionaryIDictionaryKeystringDefaultdouble
Returns
AsInteger(IDictionary<string, object>, string)
Returns the Value of Key
public static int AsInteger(this IDictionary<string, object> Data, string Key)
Parameters
DataIDictionary<string, object>Keystring
Returns
AsInteger(IDictionary, string)
Returns the Value of FlagName if exists, else Default
public static int AsInteger(this IDictionary Dictionary, string Key)
Parameters
DictionaryIDictionaryKeystring
Returns
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
DictionaryIDictionaryKeystringDefaultint
Returns
AsObject(IDictionary<string, object>, string)
Returns the Value of Key
public static object AsObject(this IDictionary<string, object> Data, string Key)
Parameters
DataIDictionary<string, object>Keystring
Returns
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
DictionaryIDictionaryKeystringDefaultobject
Returns
AsString(IDictionary<string, object>, string)
Returns the Value of Key
public static string AsString(this IDictionary<string, object> Data, string Key)
Parameters
DataIDictionary<string, object>Keystring
Returns
AsString(IDictionary, string)
Returns the Value of FlagName if exists, else the empty string
public static string AsString(this IDictionary Dictionary, string Key)
Parameters
DictionaryIDictionaryKeystring
Returns
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
DictionaryIDictionaryKeystringDefaultstring
Returns
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
SourceIDictionary<TKey, TValue>DestIDictionary<TKey, TValue>ClearSourcebool
Type Parameters
TKeyTValue
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
DictionaryIDictionary<string, string>
Returns
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
DictionaryIDictionary<string, string>ParentNodeXmlNodeListNodeNamestring
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
DictionaryIDictionary<string, string>ParentNodeXmlNodeListNodeNamestring
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
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
DictionaryIDictionary<string, string>Textstring
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
DataIDictionary<string, object>KeystringDefaultT
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
Returns
- T
Type Parameters
T
ValuesToRow(IDictionary, DataRow)
Passes values from Values to Row.
public static void ValuesToRow(this IDictionary Values, DataRow Row)
Parameters
ValuesIDictionaryRowDataRow