本文整理汇总了C#中System.Xml.Serialization.ClassMap.GetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# ClassMap.GetAttribute方法的具体用法?C# ClassMap.GetAttribute怎么用?C# ClassMap.GetAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Serialization.ClassMap
的用法示例。
在下文中一共展示了ClassMap.GetAttribute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CollectAttributeUsesNonOverlap
// Attributes might be redefined, so there is an existing attribute for the same name, skip it.
// FIXME: this is nothing more than just a hack.
// Basically it should use
// XmlSchemaComplexType.AttributeUses.
XmlSchemaObjectCollection CollectAttributeUsesNonOverlap (
XmlSchemaObjectCollection src, ClassMap map)
{
XmlSchemaObjectCollection atts = new XmlSchemaObjectCollection ();
foreach (XmlSchemaAttribute a in src)
if (map.GetAttribute (a.QualifiedName.Name, a.QualifiedName.Namespace) == null)
atts.Add (a);
return atts;
}
示例2: CollectAttributeUsesNonOverlap
// Attributes might be redefined, so there is an existing attribute for the same name, skip it.
// FIXME: this is nothing more than just a hack.
// Basically it should use
// XmlSchemaComplexType.AttributeUses.
XmlSchemaObjectCollection CollectAttributeUsesNonOverlap (
XmlSchemaObjectCollection src, ClassMap map)
{
XmlSchemaObjectCollection atts = new XmlSchemaObjectCollection ();
foreach (var a in EnumerateAttributes (src, new List<XmlSchemaAttributeGroup> ()))
if (map.GetAttribute (a.QualifiedName.Name, a.QualifiedName.Namespace) == null)
atts.Add (a);
return atts;
}
示例3: ReadAttributeMembers
void ReadAttributeMembers (ClassMap map, object ob, bool isValueList)
{
XmlTypeMapMember anyAttrMember = map.DefaultAnyAttributeMember;
int anyAttributeIndex = 0;
object anyAttributeArray = null;
while (Reader.MoveToNextAttribute())
{
XmlTypeMapMemberAttribute member = map.GetAttribute (Reader.LocalName, Reader.NamespaceURI);
if (member != null)
{
SetMemberValue (member, ob, GetValueFromXmlString (Reader.Value, member.TypeData, member.MappedType), isValueList);
}
else if (IsXmlnsAttribute(Reader.Name))
{
// If the map has NamespaceDeclarations,
// then store this xmlns to the given member.
// If the instance doesn't exist, then create.
if (map.NamespaceDeclarations != null) {
XmlSerializerNamespaces nss = this.GetMemberValue (map.NamespaceDeclarations, ob, isValueList) as XmlSerializerNamespaces;
if (nss == null) {
nss = new XmlSerializerNamespaces ();
SetMemberValue (map.NamespaceDeclarations, ob, nss, isValueList);
}
if (Reader.Prefix == "xmlns")
nss.Add (Reader.LocalName, Reader.Value);
else
nss.Add ("", Reader.Value);
}
}
else if (anyAttrMember != null)
{
XmlAttribute attr = (XmlAttribute) Document.ReadNode(Reader);
ParseWsdlArrayType (attr);
AddListValue (anyAttrMember.TypeData, ref anyAttributeArray, anyAttributeIndex++, attr, true);
}
else
ProcessUnknownAttribute(ob);
}
if (anyAttrMember != null)
{
anyAttributeArray = ShrinkArray ((Array)anyAttributeArray, anyAttributeIndex, anyAttrMember.TypeData.Type.GetElementType(), true);
SetMemberValue (anyAttrMember, ob, anyAttributeArray, isValueList);
}
Reader.MoveToElement ();
}
示例4: ReadMembers
void ReadMembers (ClassMap map, object ob, bool isValueList, bool readByOrder)
{
// Set the default values of the members
if (map.MembersWithDefault != null)
{
ArrayList members = map.MembersWithDefault;
for (int n=0; n<members.Count; n++) {
XmlTypeMapMember mem = (XmlTypeMapMember) members[n];
SetMemberValueFromAttr (mem, ob, mem.DefaultValue, isValueList);
}
}
// Reads attributes
XmlTypeMapMember anyAttrMember = map.DefaultAnyAttributeMember;
int anyAttributeIndex = 0;
object anyAttributeArray = null;
while (Reader.MoveToNextAttribute())
{
XmlTypeMapMemberAttribute member = map.GetAttribute (Reader.LocalName, Reader.NamespaceURI);
if (member != null)
{
SetMemberValue (member, ob, GetValueFromXmlString (Reader.Value, member.TypeData, member.MappedType), isValueList);
}
else if (IsXmlnsAttribute(Reader.Name))
{
// If the map has NamespaceDeclarations,
// then store this xmlns to the given member.
// If the instance doesn't exist, then create.
if (map.NamespaceDeclarations != null) {
XmlSerializerNamespaces nss = this.GetMemberValue (map.NamespaceDeclarations, ob, isValueList) as XmlSerializerNamespaces;
if (nss == null) {
nss = new XmlSerializerNamespaces ();
SetMemberValue (map.NamespaceDeclarations, ob, nss, isValueList);
}
if (Reader.Prefix == "xmlns")
nss.Add (Reader.LocalName, Reader.Value);
else
nss.Add ("", Reader.Value);
}
}
else if (anyAttrMember != null)
{
XmlAttribute attr = (XmlAttribute) Document.ReadNode(Reader);
ParseWsdlArrayType (attr);
AddListValue (anyAttrMember.TypeData, ref anyAttributeArray, anyAttributeIndex++, attr, true);
}
else
ProcessUnknownAttribute(ob);
}
if (anyAttrMember != null)
{
anyAttributeArray = ShrinkArray ((Array)anyAttributeArray, anyAttributeIndex, anyAttrMember.TypeData.Type.GetElementType(), true);
SetMemberValue (anyAttrMember, ob, anyAttributeArray, isValueList);
}
if (!isValueList)
{
Reader.MoveToElement();
if (Reader.IsEmptyElement)
return;
Reader.ReadStartElement();
}
// Reads elements
bool[] readFlag = new bool[(map.ElementMembers != null) ? map.ElementMembers.Count : 0];
bool hasAnyReturnMember = (isValueList && _format == SerializationFormat.Encoded && map.ReturnMember != null
&& map.ReturnMember.TypeData.Type == typeof(object));
Reader.MoveToContent();
int[] indexes = null;
object[] flatLists = null;
Fixup fixup = null;
int ind = 0;
int maxInd;
if (readByOrder) {
if (map.ElementMembers != null) maxInd = map.ElementMembers.Count;
else maxInd = 0;
}
else
maxInd = int.MaxValue;
if (map.FlatLists != null)
{
indexes = new int[map.FlatLists.Count];
flatLists = new object[map.FlatLists.Count];
foreach (XmlTypeMapMemberExpandable mem in map.FlatLists)
if (IsReadOnly (mem, ob, isValueList)) flatLists[mem.FlatArrayIndex] = mem.GetValue (ob);
}
if (_format == SerializationFormat.Encoded && map.ElementMembers != null)
{
//.........这里部分代码省略.........