當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。