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


C# SerializationInfo.GetInt16方法代码示例

本文整理汇总了C#中SerializationInfo.GetInt16方法的典型用法代码示例。如果您正苦于以下问题:C# SerializationInfo.GetInt16方法的具体用法?C# SerializationInfo.GetInt16怎么用?C# SerializationInfo.GetInt16使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SerializationInfo的用法示例。


在下文中一共展示了SerializationInfo.GetInt16方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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";
		SerializationInfo serinfo1 = null;
		Type tpName = null;
		try {
			do
			{
				tpName = Type.GetType("System.Int32");
				serinfo1 = new SerializationInfo(tpName, new FormatterConverter());
				iCountTestcases++;
				if(serinfo1.MemberCount != 0)
				{
					iCountErrors++;
					Console.WriteLine("Err_0256csd! Wrong number of members, " + serinfo1.MemberCount.ToString());
				}
				serinfo1.AddValue("MyOwnField", 5, typeof(Int32));
				iCountTestcases++;
				if(serinfo1.MemberCount != 1)
				{
					iCountErrors++;
					Console.WriteLine("Err_8564cfdg! Wrong number of members, " + serinfo1.MemberCount.ToString());
				}
				iCountTestcases++;
				if(serinfo1.GetInt16("MyOwnField") != 5)
				{
					iCountErrors++;
					Console.WriteLine("Err_675349fd! Wrong value returned, " + serinfo1.GetInt16("MyOwnField"));
				}
			} while (false);
			} catch (Exception exc_general ) {
			++iCountErrors;
			Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.StackTrace);
		}
		if ( iCountErrors == 0 )
		{
			Console.WriteLine( "paSs.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases.ToString());
			return true;
		}
		else
		{
			Console.WriteLine("FAiL!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors.ToString()+" , BugNums?: "+s_strActiveBugNums );
			return false;
		}
	}
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:48,代码来源:co3848get_membercount.cs

示例2: runTest


//.........这里部分代码省略.........
					strLoc="Loc_56473vd_" + i;
					sbtValue = (SByte)i;;
					strValue = "SByte_" + i;
					serinfo1.AddValue(strValue, sbtValue);
					iCountTestcases++;
					if(serinfo1.GetSByte(strValue)!= sbtValue)
					{
						iCountErrors++;
						Console.WriteLine("Err_4627fds_" + i + "! Wrong Sbyte returned, " + serinfo1.GetSByte(strValue));
					}
				}
				Console.WriteLine("Byte ticks, " + Environment.TickCount);
				for(int i=(int)Byte.MinValue; i<(int)Byte.MaxValue; i++) {
					strLoc="Loc_01192ds_" + i;
					btValue = (Byte)i;;
					strValue = "Byte_" + i;
					serinfo1.AddValue(strValue, btValue);
					iCountTestcases++;
					if(serinfo1.GetByte(strValue)!= btValue)
					{
						iCountErrors++;
						Console.WriteLine("Err_0267fe_" + i + "! Wrong byte returned, " + serinfo1.GetByte(strValue));
					}
				}
				Console.WriteLine("Int16 ticks, " + Environment.TickCount);
				for(int i=0; i<50; i++) {
					strLoc="Loc_012965565ds_" + i;
					i16Value = (short)((int)Int16.MaxValue * rnd1.NextDouble());
					if(rnd1.NextDouble()<0.5)
					i16Value = (short)(-1 * i16Value);
					strValue = "Int16_" + i;
					serinfo1.AddValue(strValue, i16Value);
					iCountTestcases++;
					if(serinfo1.GetInt16(strValue)!= i16Value)
					{
						iCountErrors++;
						Console.WriteLine("Err_0267fe_" + i + "! Wrong value returned, " + serinfo1.GetInt16(strValue));
					}
				}
				Console.WriteLine("Int32 ticks, " + Environment.TickCount);
				for(int i=0; i<50; i++) {
					strLoc="Loc_015643ds_" + i;
					i32Value = (int)(Int32.MaxValue * rnd1.NextDouble());
					if(rnd1.NextDouble()<0.5)
					i32Value = (-1 * i32Value);
					strValue = "Int32_" + i;
					serinfo1.AddValue(strValue, i32Value);
					iCountTestcases++;
					if(serinfo1.GetInt32(strValue)!= i32Value)
					{
						iCountErrors++;
						Console.WriteLine("Err_5427ds_" + i + "! Wrong value returned, " + serinfo1.GetInt32(strValue));
					}
				}
				Console.WriteLine("Int64 ticks, " + Environment.TickCount);
				for(int i=0; i<50; i++) {
					strLoc="Loc_625bfg_" + i;
					i64Value = (long)((long)Int64.MaxValue * rnd1.NextDouble());
					if(rnd1.NextDouble()<0.5)
					i64Value = (long)(-1 * i64Value);
					strValue = "Int64_" + i;
					serinfo1.AddValue(strValue, i64Value);
					iCountTestcases++;
					if(serinfo1.GetInt64(strValue)!= i64Value)
					{
						iCountErrors++;
开发者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";
		SerializationInfo serinfo1 = null;
		try {
			do
			{
				serinfo1 = new SerializationInfo(typeof(Int32), new FormatterConverter());
				iCountTestcases++;
				if(serinfo1.MemberCount != 0)
				{
					iCountErrors++;
					Console.WriteLine("Err_0256csd! Wrong number of members, " + serinfo1.MemberCount.ToString());
				}
				serinfo1.AddValue("MyOwnField", 5, typeof(Int32));
				iCountTestcases++;
				if(serinfo1.MemberCount != 1)
				{
					iCountErrors++;
					Console.WriteLine("Err_8564cfdg! Wrong number of members, " + serinfo1.MemberCount.ToString());
				}
				iCountTestcases++;
				if(serinfo1.GetInt16("MyOwnField") != 5)
				{
					iCountErrors++;
					Console.WriteLine("Err_675349fd! Wrong value returned, " + serinfo1.GetInt16("MyOwnField"));
				}
				serinfo1 = new SerializationInfo(typeof(MyOwnClass), new FormatterConverter());
				serinfo1.AddValue("MyOwnField_1", "5", typeof(Int32));
				serinfo1.AddValue("MyOwnField_2", "AnyValue", typeof(String));
				serinfo1.AddValue("MyOwnField_WhichIsNotInThisClass", "AnyValue", typeof(String));
				iCountTestcases++;
				if(serinfo1.MemberCount != 3)
				{
					iCountErrors++;
					Console.WriteLine("Err_6538fcd! Wrong number of members, " + serinfo1.MemberCount.ToString());
				}
				try {
					iCountTestcases++;
					serinfo1 = new SerializationInfo(null, new FormatterConverter());
					iCountErrors++;
					Console.WriteLine("Err_653fd! Exception not thrown");
					}catch(ArgumentNullException){
					}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_6439cd! Wrong exception thrown, " + ex);
				}
				try {
					iCountTestcases++;
					serinfo1 = new SerializationInfo(typeof(Int32), null);
					iCountErrors++;
					Console.WriteLine("Err_1065753cd! Exception not thrown");
					}catch(ArgumentNullException){
					}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_5739cd! Wrong exception thrown, " + ex);
				}
			} while (false);
			} catch (Exception exc_general ) {
			++iCountErrors;
			Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.StackTrace);
		}
		if ( iCountErrors == 0 )
		{
			Console.WriteLine( "paSs.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases.ToString());
			return true;
		}
		else
		{
			Console.WriteLine("FAiL!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors.ToString()+" , BugNums?: "+s_strActiveBugNums );
			return false;
		}
	}
开发者ID:ArildF,项目名称:masters,代码行数:76,代码来源:co3884ctor_tp_if.cs


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