本文整理汇总了C#中System.Xml.Serialization.StructMapping.SetSequence方法的典型用法代码示例。如果您正苦于以下问题:C# StructMapping.SetSequence方法的具体用法?C# StructMapping.SetSequence怎么用?C# StructMapping.SetSequence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Serialization.StructMapping
的用法示例。
在下文中一共展示了StructMapping.SetSequence方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImportStructType
private StructMapping ImportStructType(XmlSchemaType type, string typeNs, string identifier, Type baseType, bool arrayLike)
{
TypeDesc baseTypeDesc = null;
TypeMapping baseMapping = null;
bool isRootType = false;
if (!type.DerivedFrom.IsEmpty)
{
baseMapping = ImportType(type.DerivedFrom, typeof(TypeMapping), null, TypeFlags.CanBeElementValue | TypeFlags.CanBeTextValue, false);
if (baseMapping is StructMapping)
baseTypeDesc = ((StructMapping)baseMapping).TypeDesc;
else if (baseMapping is ArrayMapping)
{
baseMapping = ((ArrayMapping)baseMapping).TopLevelMapping;
if (baseMapping != null)
{
baseMapping.ReferencedByTopLevelElement = false;
baseMapping.ReferencedByElement = true;
baseTypeDesc = baseMapping.TypeDesc;
}
}
else
baseMapping = null;
}
if (baseTypeDesc == null && baseType != null)
baseTypeDesc = Scope.GetTypeDesc(baseType);
if (baseMapping == null)
{
baseMapping = GetRootMapping();
isRootType = true;
}
Mapping previousMapping = (Mapping)ImportedMappings[type];
if (previousMapping != null)
{
if (previousMapping is StructMapping)
{
return (StructMapping)previousMapping;
}
else if (arrayLike && previousMapping is ArrayMapping)
{
ArrayMapping arrayMapping = (ArrayMapping)previousMapping;
if (arrayMapping.TopLevelMapping != null)
{
return arrayMapping.TopLevelMapping;
}
}
else
{
throw new InvalidOperationException(SR.Format(SR.XmlTypeUsedTwice, type.QualifiedName.Name, type.QualifiedName.Namespace));
}
}
StructMapping structMapping = new StructMapping();
structMapping.IsReference = Schemas.IsReference(type);
TypeFlags flags = TypeFlags.Reference;
if (type is XmlSchemaComplexType)
{
if (((XmlSchemaComplexType)type).IsAbstract)
flags |= TypeFlags.Abstract;
}
identifier = Accessor.UnescapeName(identifier);
string typeName = type.Name == null || type.Name.Length == 0 ? GenerateUniqueTypeName(identifier, typeNs) : GenerateUniqueTypeName(identifier);
structMapping.TypeDesc = new TypeDesc(typeName, typeName, TypeKind.Struct, baseTypeDesc, flags);
structMapping.Namespace = typeNs;
structMapping.TypeName = type.Name == null || type.Name.Length == 0 ? null : identifier;
structMapping.BaseMapping = (StructMapping)baseMapping;
if (!arrayLike)
ImportedMappings.Add(type, structMapping);
CodeIdentifiers members = new CodeIdentifiers();
CodeIdentifiers membersScope = structMapping.BaseMapping.Scope.Clone();
members.AddReserved(typeName);
membersScope.AddReserved(typeName);
AddReservedIdentifiersForDataBinding(members);
if (isRootType)
AddReservedIdentifiersForDataBinding(membersScope);
bool needExplicitOrder = false;
structMapping.Members = ImportTypeMembers(type, typeNs, identifier, members, membersScope, structMapping, ref needExplicitOrder, true, true);
if (!IsAllGroup(type))
{
if (needExplicitOrder && !GenerateOrder)
{
structMapping.SetSequence();
}
else if (GenerateOrder)
{
structMapping.IsSequence = true;
}
}
for (int i = 0; i < structMapping.Members.Length; i++)
{
StructMapping declaringMapping;
MemberMapping baseMember = ((StructMapping)baseMapping).FindDeclaringMapping(structMapping.Members[i], out declaringMapping, structMapping.TypeName);
if (baseMember != null && baseMember.TypeDesc != structMapping.Members[i].TypeDesc)
throw new InvalidOperationException(SR.Format(SR.XmlIllegalOverride, type.Name, baseMember.Name, baseMember.TypeDesc.FullName, structMapping.Members[i].TypeDesc.FullName, declaringMapping.TypeDesc.FullName));
}
structMapping.Scope = membersScope;
Scope.AddTypeMapping(structMapping);
//.........这里部分代码省略.........
示例2: ImportStructType
private StructMapping ImportStructType(XmlSchemaType type, string typeNs, string identifier, Type baseType, bool arrayLike)
{
TypeDesc baseTypeDesc = null;
TypeMapping topLevelMapping = null;
bool flag = false;
if (!type.DerivedFrom.IsEmpty)
{
topLevelMapping = this.ImportType(type.DerivedFrom, typeof(TypeMapping), null, TypeFlags.CanBeElementValue | TypeFlags.CanBeTextValue, false);
if (topLevelMapping is StructMapping)
{
baseTypeDesc = ((StructMapping) topLevelMapping).TypeDesc;
}
else if (topLevelMapping is ArrayMapping)
{
topLevelMapping = ((ArrayMapping) topLevelMapping).TopLevelMapping;
if (topLevelMapping != null)
{
topLevelMapping.ReferencedByTopLevelElement = false;
topLevelMapping.ReferencedByElement = true;
baseTypeDesc = topLevelMapping.TypeDesc;
}
}
else
{
topLevelMapping = null;
}
}
if ((baseTypeDesc == null) && (baseType != null))
{
baseTypeDesc = base.Scope.GetTypeDesc(baseType);
}
if (topLevelMapping == null)
{
topLevelMapping = base.GetRootMapping();
flag = true;
}
Mapping mapping2 = (Mapping) base.ImportedMappings[type];
if (mapping2 != null)
{
if (mapping2 is StructMapping)
{
return (StructMapping) mapping2;
}
if (!arrayLike || !(mapping2 is ArrayMapping))
{
throw new InvalidOperationException(Res.GetString("XmlTypeUsedTwice", new object[] { type.QualifiedName.Name, type.QualifiedName.Namespace }));
}
ArrayMapping mapping3 = (ArrayMapping) mapping2;
if (mapping3.TopLevelMapping != null)
{
return mapping3.TopLevelMapping;
}
}
StructMapping mapping4 = new StructMapping {
IsReference = base.Schemas.IsReference(type)
};
TypeFlags reference = TypeFlags.Reference;
if ((type is XmlSchemaComplexType) && ((XmlSchemaComplexType) type).IsAbstract)
{
reference |= TypeFlags.Abstract;
}
identifier = Accessor.UnescapeName(identifier);
string name = ((type.Name == null) || (type.Name.Length == 0)) ? this.GenerateUniqueTypeName(identifier, typeNs) : base.GenerateUniqueTypeName(identifier);
mapping4.TypeDesc = new TypeDesc(name, name, TypeKind.Struct, baseTypeDesc, reference);
mapping4.Namespace = typeNs;
mapping4.TypeName = ((type.Name == null) || (type.Name.Length == 0)) ? null : identifier;
mapping4.BaseMapping = (StructMapping) topLevelMapping;
if (!arrayLike)
{
base.ImportedMappings.Add(type, mapping4);
}
CodeIdentifiers scope = new CodeIdentifiers();
CodeIdentifiers identifiers2 = mapping4.BaseMapping.Scope.Clone();
scope.AddReserved(name);
identifiers2.AddReserved(name);
base.AddReservedIdentifiersForDataBinding(scope);
if (flag)
{
base.AddReservedIdentifiersForDataBinding(identifiers2);
}
bool needExplicitOrder = false;
mapping4.Members = this.ImportTypeMembers(type, typeNs, identifier, scope, identifiers2, mapping4, ref needExplicitOrder, true, true);
if (!this.IsAllGroup(type))
{
if (needExplicitOrder && !this.GenerateOrder)
{
mapping4.SetSequence();
}
else if (this.GenerateOrder)
{
mapping4.IsSequence = true;
}
}
for (int i = 0; i < mapping4.Members.Length; i++)
{
StructMapping mapping5;
MemberMapping mapping6 = ((StructMapping) topLevelMapping).FindDeclaringMapping(mapping4.Members[i], out mapping5, mapping4.TypeName);
if ((mapping6 != null) && (mapping6.TypeDesc != mapping4.Members[i].TypeDesc))
{
throw new InvalidOperationException(Res.GetString("XmlIllegalOverride", new object[] { type.Name, mapping6.Name, mapping6.TypeDesc.FullName, mapping4.Members[i].TypeDesc.FullName, mapping5.TypeDesc.FullName }));
//.........这里部分代码省略.........