本文整理汇总了C#中SerializationInfo.GetEnumerator方法的典型用法代码示例。如果您正苦于以下问题:C# SerializationInfo.GetEnumerator方法的具体用法?C# SerializationInfo.GetEnumerator怎么用?C# SerializationInfo.GetEnumerator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SerializationInfo
的用法示例。
在下文中一共展示了SerializationInfo.GetEnumerator方法的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;
Int32 iNumberOfMembers;
String[] arrNames = null;
Object[] arrValues = null;
SerializationInfoEnumerator serenum1 = null;
int iNum = 0;
SerializationEntry serEnt1;
try {
do
{
serinfo1 = new SerializationInfo(typeof(Int32), new FormatterConverter());
iNumberOfMembers = 50;
arrNames = new String[iNumberOfMembers];
arrValues = new Object[iNumberOfMembers];
for(int i=0; i<iNumberOfMembers;i++)
{
arrNames[i] = i.ToString();
arrValues[i] = i;
serinfo1.AddValue(arrNames[i], arrValues[i], typeof(Int32));
}
serenum1 = serinfo1.GetEnumerator();
iNum = 0;
while(serenum1.MoveNext())
{
iCountTestcases++;
serEnt1 = serenum1.Current;
if(!serEnt1.ObjectType.Equals(typeof(Int32)))
{
iCountErrors++;
Console.WriteLine("Err_4753fg_" + iNum.ToString() + "! Wrong value, " + serEnt1.ObjectType);
}
if(!serEnt1.Name.Equals(iNum.ToString()))
{
iCountErrors++;
Console.WriteLine("Err_7439gdg_" + iNum.ToString() + "! Wrong value, " + serEnt1.Name);
}
if((Int32)serEnt1.Value != iNum)
{
iCountErrors++;
Console.WriteLine("Err_7439gdg_" + iNum.ToString() + "! Wrong value, " + serEnt1.Value);
}
iNum++;
}
tpName = Type.GetType("System.Int16");
serinfo1 = new SerializationInfo(tpName, new FormatterConverter());
serenum1 = serinfo1.GetEnumerator();
iCountTestcases++;
if(serenum1.MoveNext())
{
iCountErrors++;
Console.WriteLine("Err_03576bfd! most peculiar, MoveNext returned true!");
}
try
{
iCountTestcases++;
serEnt1 = serenum1.Current;
iCountErrors++;
Console.WriteLine("Err_0346gsdf! Exception not thrown");
}
catch(InvalidOperationException){}
catch(Exception ex)
{
iCountErrors++;
Console.WriteLine("Err_752gs! Wrong Exception thrown," + ex.ToString());
}
} 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;
}
}
示例2: SetObjectData
[System.Security.SecurityCritical] // auto-generated
internal void SetObjectData(SerializationInfo info, StreamingContext context)
{
if (info == null)
throw new ArgumentNullException("info");
Contract.EndContractBlock();
if (fSoap)
{
SetObjectFromSoapData(info);
}
else
{
SerializationInfoEnumerator siEnum = info.GetEnumerator();
while (siEnum.MoveNext())
{
FillHeader(siEnum.Name, siEnum.Value);
}
if ((context.State == StreamingContextStates.Remoting) &&
(context.Context != null))
{
Header[] h = context.Context as Header[];
if(null != h)
{
for (int i=0; i<h.Length; i++)
FillHeader(h[i].Name, h[i].Value);
}
}
}
} // SetObjectData
示例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;
Type tpName = null;
Int32 iNumberOfMembers;
String[] arrNames = null;
Object[] arrValues = null;
Int32 iNum = 0;
SerializationInfoEnumerator serenum1 = null;
try {
tpName = Type.GetType("System.Int32");
serinfo1 = new SerializationInfo(tpName, new FormatterConverter());
iNumberOfMembers = 50;
arrNames = new String[iNumberOfMembers];
arrValues = new Object[iNumberOfMembers];
for(int i=0; i<iNumberOfMembers;i++)
{
arrNames[i] = i.ToString();
arrValues[i] = i;
serinfo1.AddValue(arrNames[i], arrValues[i], typeof(Int32));
}
serenum1 = serinfo1.GetEnumerator();
serenum1 = serinfo1.GetEnumerator();
iNum = 0;
while(serenum1.MoveNext())
{
iCountTestcases++;
if(!arrValues[iNum].Equals(serenum1.Value))
{
iCountErrors++;
Console.WriteLine("Err_0246wd_" + iNum.ToString() + "! Wrong value, " + arrValues[iNum].ToString());
}
iCountTestcases++;
if(!arrNames[iNum].Equals(serenum1.Name))
{
iCountErrors++;
Console.WriteLine("Err_0246wd_" + iNum.ToString() + "! Wrong value, " + arrValues[iNum].ToString());
}
iCountTestcases++;
if(!typeof(Int32).Equals(serenum1.ObjectType))
{
iCountErrors++;
Console.WriteLine("Err_0246cds_" + iNum.ToString() + "! Wrong value, " + serenum1.ObjectType);
}
iNum++;
}
iCountTestcases++;
if(serenum1.MoveNext())
{
iCountErrors++;
Console.WriteLine("Err_925ca! most peculiar, MoveNext returned true!");
}
serenum1.Reset();
iNum = 0;
while(serenum1.MoveNext())
{
iCountTestcases++;
if(!arrValues[iNum].Equals(serenum1.Value))
{
iCountErrors++;
Console.WriteLine("Err_9834sdg_" + iNum.ToString() + "! Wrong value, " + arrValues[iNum].ToString() + " " + serenum1.Value);
}
iCountTestcases++;
if(!arrNames[iNum].Equals(serenum1.Name))
{
iCountErrors++;
Console.WriteLine("Err_24975wsdg_" + iNum.ToString() + "! Wrong value, " + arrValues[iNum].ToString());
}
iCountTestcases++;
if(!typeof(Int32).Equals(serenum1.ObjectType))
{
iCountErrors++;
Console.WriteLine("Err_9347sdg_" + iNum.ToString() + "! Wrong value, " + serenum1.ObjectType);
}
iNum++;
}
iCountTestcases++;
if(serenum1.MoveNext())
{
iCountErrors++;
Console.WriteLine("Err_925ca! most peculiar, MoveNext returned true!");
}
tpName = Type.GetType("System.Int16");
serinfo1 = new SerializationInfo(tpName, new FormatterConverter());
serenum1 = serinfo1.GetEnumerator();
iCountTestcases++;
if(serenum1.MoveNext())
{
iCountErrors++;
Console.WriteLine("Err_03576bfd! most peculiar, MoveNext returned true!");
}
serenum1.Reset();
if(serenum1.MoveNext())
{
iCountErrors++;
Console.WriteLine("Err_03576bfd! most peculiar, MoveNext returned true!");
//.........这里部分代码省略.........