本文整理汇总了C#中System.Collections.Hashtable.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Hashtable.GetType方法的具体用法?C# Hashtable.GetType怎么用?C# Hashtable.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Hashtable
的用法示例。
在下文中一共展示了Hashtable.GetType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: arr2xml
private static void arr2xml(XmlWriter xml, Hashtable data) {
string substr = "";
int status = 0;
if (data != null && data.GetType().ToString() == "System.Collections.Hashtable") {
foreach (DictionaryEntry item in data) {
if (item.Value.GetType().ToString() == "System.Collections.Hashtable") {
xml.WriteStartElement(item.Key.ToString());
Hashtable v2 = item.Value as Hashtable;
OpenPayU.arr2xml(xml, v2);
xml.WriteEndElement();
status = 0;
continue;
} else {
status = 0;
substr = item.Value.GetType().ToString();
if (substr.Length > 30)
substr = item.Value.GetType().ToString().Substring(0, 32);
if (substr == "System.Collections.Generic.Stack") {
xml.WriteStartElement(item.Key.ToString());
status = 1;
Stack<Hashtable> v3 = item.Value as Stack<Hashtable>;
foreach (Hashtable item2 in v3) {
Hashtable v4 = item2 as Hashtable;
OpenPayU.arr2xml(xml, v4);
}
xml.WriteEndElement();
continue;
}
}
if (status == 0)
xml.WriteElementString(item.Key.ToString(), item.Value.ToString());
status = 0;
}
}
}
示例2: CreateTryGetValueDelegateWrapsNonGenericDictionaries
public void CreateTryGetValueDelegateWrapsNonGenericDictionaries()
{
// Arrange
object dictionary = new Hashtable()
{
{ "foo", 42 }
};
// Act
TryGetValueDelegate d = TypeHelpers.CreateTryGetValueDelegate(dictionary.GetType());
object fooValue;
bool fooIsFound = d(dictionary, "foo", out fooValue);
object barValue;
bool barIsFound = d(dictionary, "bar", out barValue);
// Assert
Assert.True(fooIsFound);
Assert.Equal(42, fooValue);
Assert.False(barIsFound);
Assert.Null(barValue);
}
示例3: CreatingHashes
public void CreatingHashes()
{
var hash = new Hashtable ();
Assert.Equals (typeof(System.Collections.Hashtable), hash.GetType ());
Assert.Equals (FILL_ME_IN, hash.Count);
}
示例4: CreatingHashes
public void CreatingHashes()
{
var hash = new Hashtable ();
Assert.AreEqual(typeof(System.Collections.Hashtable), hash.GetType ());
Assert.AreEqual(0, hash.Count);
}
示例5: ResizeArray
// --------------------------------------------------------------------------
private static void ResizeArray(ref Hashtable[] oldArray, int newSize)
{
int oldSize = oldArray.Length;
System.Type elementType = oldArray.GetType().GetElementType();
Hashtable[] newArray = (Hashtable[])System.Array.CreateInstance(elementType, newSize);
int preserveLength = System.Math.Min(oldSize, newSize);
if (preserveLength > 0)
System.Array.Copy(oldArray, newArray, preserveLength);
oldArray = newArray;
}