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


C# ClassMap.GetAttribute方法代码示例

本文整理汇总了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;
		}
开发者ID:nestalk,项目名称:mono,代码行数:13,代码来源:XmlSchemaImporter.cs

示例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;
		}
开发者ID:frje,项目名称:SharpLang,代码行数:13,代码来源:XmlSchemaImporter.cs

示例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 ();
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:48,代码来源:XmlSerializationReaderInterpreter.cs

示例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)
			{
//.........这里部分代码省略.........
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:101,代码来源:XmlSerializationReaderInterpreter.cs


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