当前位置: 首页>>代码示例>>C#>>正文


C# SerializationInfo.GetSingle方法代码示例

本文整理汇总了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");
 }
开发者ID:hxzpily,项目名称:projectanarchy,代码行数:5,代码来源:Cursor3DProperties.cs

示例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);
开发者ID:ArildF,项目名称:masters,代码行数:67,代码来源:co3888get_most.cs

示例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++;
//.........这里部分代码省略.........
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:101,代码来源:co3949getobjectdata_sersc.cs


注:本文中的SerializationInfo.GetSingle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。