本文整理汇总了C#中SerializationInfo.GetSingle方法的典型用法代码示例。如果您正苦于以下问题:C# SerializationInfo.GetSingle方法的具体用法?C# SerializationInfo.GetSingle怎么用?C# SerializationInfo.GetSingle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SerializationInfo
的用法示例。
在下文中一共展示了SerializationInfo.GetSingle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HeightmapCursorProperties
protected HeightmapCursorProperties(SerializationInfo info, StreamingContext context)
: base(info, context)
{
_height = info.GetSingle("_height");
}
示例2: runTest
//.........这里部分代码省略.........
strValue = "UInt64_" + i;
serinfo1.AddValue(strValue, ui64Value);
iCountTestcases++;
if(serinfo1.GetUInt64(strValue)!= ui64Value)
{
iCountErrors++;
Console.WriteLine("Err_6583fd_" + i + "! Wrong value returned, " + serinfo1.GetUInt64(strValue));
}
}
Console.WriteLine("Double ticks, " + Environment.TickCount);
for(int i=0; i<50; i++) {
strLoc="Loc_7539cd_" + i;
dblValue = Double.MaxValue * rnd1.NextDouble();
if(rnd1.NextDouble()<0.5)
dblValue = (-1 * dblValue);
strValue = "Double_" + i;
serinfo1.AddValue(strValue, dblValue);
iCountTestcases++;
if(serinfo1.GetDouble(strValue)!= dblValue)
{
iCountErrors++;
Console.WriteLine("Err_653cfd_" + i + "! Wrong value returned, " + serinfo1.GetDouble(strValue));
}
}
Console.WriteLine("Single ticks, " + Environment.TickCount);
for(int i=0; i<50; i++) {
strLoc="Loc_0247fd_" + i;
sglValue = (float)(Single.MaxValue * rnd1.NextDouble());
if(rnd1.NextDouble()<0.5)
sglValue = (-1 * sglValue);
strValue = "Single_" + i;
serinfo1.AddValue(strValue, sglValue);
iCountTestcases++;
if(serinfo1.GetSingle(strValue)!= sglValue)
{
iCountErrors++;
Console.WriteLine("Err_0468fd_" + i + "! Wrong value returned, " + serinfo1.GetSingle(strValue));
}
}
strValue = "This is a String";
serinfo1.AddValue("String_1", strValue);
iCountTestcases++;
if(!serinfo1.GetString("String_1").Equals(strValue))
{
iCountErrors++;
Console.WriteLine("Err_0945csd! wrong value returned, " + serinfo1.GetString("String_1"));
}
strValue = "";
serinfo1.AddValue("String_2", strValue);
iCountTestcases++;
if(!serinfo1.GetString("String_2").Equals(String.Empty))
{
iCountErrors++;
Console.WriteLine("Err_0945csd! wrong value returned, " + serinfo1.GetString("String_2"));
}
strValue = null;
serinfo1.AddValue("String_3", strValue);
iCountTestcases++;
if(serinfo1.GetString("String_3") != null)
{
iCountErrors++;
Console.WriteLine("Err_0945csd! wrong value returned, " + serinfo1.GetString("String_3"));
}
try {
iCountTestcases++;
serinfo1.AddValue("String_2", fValue);
示例3: runTest
public bool runTest()
{
Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer);
int iCountErrors = 0;
int iCountTestcases = 0;
String strLoc = "Loc_000oo";
Hashtable dic1;
Int32 iNumberOfItems = 10;
SerializationInfo ser1;
Object[] serKeys;
Object[] serValues;
Hashtable hsh1;
Hashtable hsh3;
Hashtable hsh4;
DictionaryEntry[] strValueArr;
MemoryStream ms1;
try
{
do
{
strLoc = "Loc_8345vdfv";
dic1 = new Hashtable();
for(int i=0; i<iNumberOfItems; i++)
{
dic1.Add(i, "String_" + i);
}
ser1 = new SerializationInfo(typeof(Hashtable), new FormatterConverter());
dic1.GetObjectData(ser1, new StreamingContext());
iCountTestcases++;
if(ser1.GetSingle("LoadFactor") != 0.72f)
{
iCountErrors++;
Console.WriteLine("Err_748cdg! Expected value not returned, " + ser1.GetSingle("LoadFactor"));
}
if(ser1.GetInt32("Version") != 11)
{
iCountErrors++;
Console.WriteLine("Err_01823csdf! Expected value not returned, " + ser1.GetSingle("Version"));
}
if(ser1.GetSingle("HashSize") != 23)
{
iCountErrors++;
Console.WriteLine("Err_7132fgfg! Expected value not returned, " + ser1.GetSingle("LoadFactor"));
}
serKeys = (Object[])ser1.GetValue("Keys", typeof(Object[]));
serValues = (Object[])ser1.GetValue("Values", typeof(Object[]));
Array.Sort(serKeys);
Array.Sort(serValues);
for(int i=0; i<iNumberOfItems; i++)
{
if((Int32)serKeys[i] != i)
{
iCountErrors++;
Console.WriteLine("Err_1nd342_" + i + "! Expected value not returned, " + i);
}
if(!((String)serValues[i]).Equals("String_" + i))
{
iCountErrors++;
Console.WriteLine("Err_7539fdg_" + i + "! Expected value not returned, " + i);
}
}
try
{
iCountTestcases++;
dic1.GetObjectData(null, new StreamingContext());
iCountErrors++;
Console.WriteLine("Err_7439dg! Exception not thrown");
}
catch(ArgumentNullException)
{
}
catch(Exception ex)
{
iCountErrors++;
Console.WriteLine("Err_6572fdg! Unexpected exception thrown, " + ex);
}
iCountTestcases++;
hsh1 = new Hashtable();
for(int i=0; i<10; i++)
{
hsh1.Add("Key_" + i, "Value_" + i);
}
BinaryFormatter formatter = new BinaryFormatter();
ms1 = new MemoryStream();
formatter.Serialize(ms1, hsh1);
ms1.Position = 0;
hsh4 = (Hashtable)formatter.Deserialize(ms1);
if(hsh4.Count != hsh1.Count)
{
iCountErrors++;
Console.WriteLine("Err_072xsf! Expected value not returned, " + hsh4.Count);
}
strValueArr = new DictionaryEntry[hsh4.Count];
hsh4.CopyTo(strValueArr, 0);
hsh3 = new Hashtable();
for(int i=0; i<10; i++)
{
if(!hsh4.Contains("Key_" + i))
{
iCountErrors++;
//.........这里部分代码省略.........