本文整理汇总了C#中XmlObjectSerializerReadContext.GetMemberIndexWithRequiredMembers方法的典型用法代码示例。如果您正苦于以下问题:C# XmlObjectSerializerReadContext.GetMemberIndexWithRequiredMembers方法的具体用法?C# XmlObjectSerializerReadContext.GetMemberIndexWithRequiredMembers怎么用?C# XmlObjectSerializerReadContext.GetMemberIndexWithRequiredMembers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlObjectSerializerReadContext
的用法示例。
在下文中一共展示了XmlObjectSerializerReadContext.GetMemberIndexWithRequiredMembers方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReflectionReadMembers
private void ReflectionReadMembers(object obj, XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context, XmlDictionaryString[] memberNames, XmlDictionaryString[] memberNamespaces)
{
int memberCount = _classContract.MemberNames.Length;
context.IncrementItemCount(memberCount);
int memberIndex = -1;
int firstRequiredMember;
bool[] requiredMembers = GetRequiredMembers(_classContract, out firstRequiredMember);
bool hasRequiredMembers = (firstRequiredMember < memberCount);
int requiredIndex = hasRequiredMembers ? firstRequiredMember : -1;
int index = -1;
while (true)
{
if (!XmlObjectSerializerReadContext.MoveToNextElement(xmlReader))
{
return;
}
if (hasRequiredMembers)
{
index = context.GetMemberIndexWithRequiredMembers(xmlReader, memberNames, memberNamespaces, memberIndex, requiredIndex, null);
}
else
{
index = context.GetMemberIndex(xmlReader, memberNames, memberNamespaces, memberIndex, null);
}
ReflectionReadMember(obj, index, xmlReader, context, memberNames, memberNamespaces);
memberIndex = index;
requiredIndex = index + 1;
}
}
示例2: ReflectionReadMembers
protected override void ReflectionReadMembers(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context, XmlDictionaryString[] memberNames, XmlDictionaryString[] memberNamespaces, ClassDataContract classContract, ref object obj)
{
int memberCount = classContract.MemberNames.Length;
context.IncrementItemCount(memberCount);
int memberIndex = -1;
int firstRequiredMember;
bool[] requiredMembers = GetRequiredMembers(classContract, out firstRequiredMember);
bool hasRequiredMembers = (firstRequiredMember < memberCount);
int requiredIndex = hasRequiredMembers ? firstRequiredMember : -1;
DataMember[] members = new DataMember[memberCount];
int reflectedMemberCount = ReflectionGetMembers(classContract, members);
Debug.Assert(reflectedMemberCount == memberCount, "The value returned by ReflectionGetMembers() should equal to memberCount.");
while (true)
{
if (!XmlObjectSerializerReadContext.MoveToNextElement(xmlReader))
{
return;
}
if (hasRequiredMembers)
{
memberIndex = context.GetMemberIndexWithRequiredMembers(xmlReader, memberNames, memberNamespaces, memberIndex, requiredIndex, null);
}
else
{
memberIndex = context.GetMemberIndex(xmlReader, memberNames, memberNamespaces, memberIndex, null);
}
// GetMemberIndex returns memberNames.Length if member not found
if (memberIndex < members.Length)
{
ReflectionReadMember(xmlReader, context, classContract, ref obj, memberIndex, members);
requiredIndex = memberIndex + 1;
}
}
}