• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Serialization.XmlElementAttribute类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Xml.Serialization.XmlElementAttribute的典型用法代码示例。如果您正苦于以下问题:C# XmlElementAttribute类的具体用法?C# XmlElementAttribute怎么用?C# XmlElementAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



XmlElementAttribute类属于System.Xml.Serialization命名空间,在下文中一共展示了XmlElementAttribute类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ElementNameDefault

		public void ElementNameDefault ()
		{
			XmlElementAttribute attr = new XmlElementAttribute ();
			Assert.AreEqual (string.Empty, attr.ElementName, "#1");

			attr.ElementName = null;
			Assert.AreEqual (string.Empty, attr.ElementName, "#2");
		}
开发者ID:nobled,项目名称:mono,代码行数:8,代码来源:XmlElementAttributeTests.cs


示例2: Insert

        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public void Insert(int index, XmlElementAttribute value)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            _list.Insert(index, value);
        }
开发者ID:SamuelEnglard,项目名称:corefx,代码行数:12,代码来源:XmlElementAttributes.cs


示例3: Add

        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public int Add(XmlElementAttribute value)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            int index = _list.Count;
            _list.Add(value);
            return index;
        }
开发者ID:SamuelEnglard,项目名称:corefx,代码行数:14,代码来源:XmlElementAttributes.cs


示例4: Remove

        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public void Remove(XmlElementAttribute value)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            if (!_list.Remove(value))
            {
                throw new ArgumentException(SR.Arg_RemoveArgNotFound);
            }
        }
开发者ID:SamuelEnglard,项目名称:corefx,代码行数:15,代码来源:XmlElementAttributes.cs


示例5: DifferentItemTypes

		public void DifferentItemTypes()
		{
			XmlElementAttribute element1 = new XmlElementAttribute("myname", typeof(SerializeMe));
			XmlElementAttribute element2 = new XmlElementAttribute("myname", typeof(SerializeMeToo));

			atts1.XmlElements.Add(element1);
			atts2.XmlElements.Add(element2);

			ov1.Add(typeof(SerializeMe), atts1);
			ov2.Add(typeof(SerializeMe), atts2);

			ThumbprintHelpers.DifferentThumbprint(ov1, ov2);
		}
开发者ID:zanyants,项目名称:mvp.xml,代码行数:13,代码来源:XmlElementThumbprintTests.cs


示例6: SameDataType

		public void SameDataType()
		{
			XmlElementAttribute element1 = new XmlElementAttribute("myname", typeof(SerializeMe));
			element1.DataType = "myfirstxmltype";
			XmlElementAttribute element2 = new XmlElementAttribute("myname", typeof(SerializeMe));
			element2.DataType = "myfirstxmltype";

			atts1.XmlElements.Add(element1);
			atts2.XmlElements.Add(element2);

			ov1.Add(typeof(SerializeMe), atts1);
			ov2.Add(typeof(SerializeMe), atts2);

			ThumbprintHelpers.SameThumbprint(ov1, ov2);
		}
开发者ID:zanyants,项目名称:mvp.xml,代码行数:15,代码来源:XmlElementThumbprintTests.cs


示例7: AddSimpleXMLElement

        private static void AddSimpleXMLElement(FileLevelInfo info, XmlElementAttribute xea, ClassSnippet snip, FieldInfo finfo)
        {
            string fieldName = xea.ElementName;
              string dtype = SetupSimpleType(info, snip, xea.DataType, fieldName, finfo.FieldType.Name);

              string nodeGetter = "pNode->FirstChildElement(\"" + fieldName + "\")";

              snip.fromXml += "\t" + fieldName + " = FromString_" + dtype + "(pNode, GetValue(\"" + fieldName + "\", pNode->FirstChildElement(\"" + fieldName + "\"), pNode));\n";
              snip.toXml += "\tTiXmlElement* n" + fieldName + " = new TiXmlElement(\"" + fieldName+ "\");\n";
              snip.toXml += "\tTiXmlText* nt" + fieldName + " = new TiXmlText(ToString_" + dtype + "(" + fieldName + "));\n";
              snip.toXml += "\tn" + fieldName + "->LinkEndChild(nt"+fieldName+");\n";
              snip.toXml += "\tpEm->LinkEndChild(n" + fieldName + ");\n";

              snip.declarations += "\t" + dtype + " " + fieldName + ";\n";
        }
开发者ID:samhendley,项目名称:dnp3,代码行数:15,代码来源:CppBinder.cs


示例8: VewerkData

        /// <summary>
        /// verwerk de data in het project object tot XML file
        /// </summary>
        /// <param name="proj">te verwerken tot XML file</param>
        /// <param name="newFile">moet er een nieuw bestand gemaakt worden</param>
        /// <returns>succes boolean</returns>
        public bool VewerkData(Project proj, bool newFile)
        {
            if (newFile)
            {
                NewNameFile();
            }
            filename = "result" + count.ToString() + ".xml";

            // elk overridden field, property, of type heeft een XmlAttributes instance nodig.
            XmlAttributes xmlAttrs = new XmlAttributes();
            // maken van het attribuut
            XmlElementAttribute attr = new XmlElementAttribute();
            attr.ElementName = "newVogel";
            attr.Type = typeof(Vogel);

            xmlAttrs.XmlElements.Add(attr);

            // maken van het override attribuut
            XmlAttributeOverrides attrOverrides = new XmlAttributeOverrides();

            // voeg de override waarde toe aan de lijst met het veld dat de inheritance heeft samen met de attribuuten
            attrOverrides.Add(typeof(Waarneming), "Dier", xmlAttrs);

            try
            {
                Type t = typeof(Code_Layer.Project);
                XmlSerializer xmls = new XmlSerializer(t, attrOverrides);
                using (FileStream fs = new FileStream(XMLPath + filename, FileMode.Create))
                {
                    xmls.Serialize(fs, proj);
                }
            }
            catch (Exception e)//error afhandelen
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.InnerException);
                Console.WriteLine(e.StackTrace);
                return false;
            }
            return true;
        }
开发者ID:chaoskie,项目名称:LP,代码行数:47,代码来源:XMLHandler.cs


示例9: DeserializeLocations

        /// <summary>
        /// Загрузка дерева локаций из XML-файла.
        /// </summary>
        /// <param name="fileName">Имя файла.</param>
        /// <returns>Локация первого уровня.</returns>
        public static Location DeserializeLocations(string fileName)
        {
            XmlAttributes attrs = new XmlAttributes();

            XmlElementAttribute attr = new XmlElementAttribute();
            attr.ElementName = "Location";
            attr.Type = typeof(Location);

            attrs.XmlElements.Add(attr);

            XmlAttributeOverrides attrOverrides = new XmlAttributeOverrides();

            attrOverrides.Add(typeof(Location), "Instruments", attrs);
            XmlSerializer writter = new XmlSerializer(typeof(Location), attrOverrides);
            var path = fileName;

            FileStream file = new FileStream(path, FileMode.Open);
            Location root = (Location)writter.Deserialize(file);
            file.Close();

            return root;
        }
开发者ID:RGluschenko,项目名称:GameXML,代码行数:27,代码来源:Location.cs


示例10: DeserializeObject

        public void DeserializeObject(string filename)
        {
            XmlAttributeOverrides attrOverrides =
               new XmlAttributeOverrides();
            XmlAttributes attrs = new XmlAttributes();

            // Create an XmlElementAttribute to override the Instrument.
            XmlElementAttribute attr = new XmlElementAttribute();
            attr.ElementName = "Brass";
            attr.Type = typeof(Brass);

            // Add the XmlElementAttribute to the collection of objects.
            attrs.XmlElements.Add(attr);

            attrOverrides.Add(typeof(Orchestra), "Instruments", attrs);

            // Create the XmlSerializer using the XmlAttributeOverrides.
            XmlSerializer s =
            new XmlSerializer(typeof(Orchestra), attrOverrides);

            FileStream fs = new FileStream(filename, FileMode.Open);
            Orchestra band = (Orchestra)s.Deserialize(fs);
            Console.WriteLine("Brass:");

            /* The difference between deserializing the overridden
            XML document and serializing it is this: To read the derived
            object values, you must declare an object of the derived type
            (Brass), and cast the Instrument instance to it. */
            Brass b;
            foreach (Instrument i in band.Instruments)
            {
                b = (Brass)i;
                Console.WriteLine(
                b.Name + "\n" +
                b.IsValved);
            }
        }
开发者ID:jacksonsix,项目名称:trycodeHere,代码行数:37,代码来源:overrideSerilizer.cs


示例11: TestSerializeCollectionWithXmlElementAttribute

		public void TestSerializeCollectionWithXmlElementAttribute()
		{
			// the rule is:
			// if no type is specified or the specified type 
			//    matches the contents of the collection, 
			//    serialize each element in an element named after the member.
			// if the type does not match, or matches the collection itself,
			//    create a base wrapping element for the member, and then
			//    wrap each collection item in its own wrapping element based on type.
			
			XmlAttributeOverrides overrides = new XmlAttributeOverrides();
			XmlAttributes attr = new XmlAttributes();
			XmlElementAttribute element = new XmlElementAttribute();
			attr.XmlElements.Add(element);
			overrides.Add(typeof(StringCollectionContainer), "Messages", attr);
			
			// empty collection & no type info in XmlElementAttribute
			StringCollectionContainer container = new StringCollectionContainer();
			Serialize(container, overrides);
			AssertEquals(Infoset("<StringCollectionContainer xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />"), WriterText);
			
			// non-empty collection & no type info in XmlElementAttribute
			container.Messages.Add("hello");
			Serialize(container, overrides);
			AssertEquals (Infoset("<StringCollectionContainer xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><Messages>hello</Messages></StringCollectionContainer>"), WriterText);
			
			// non-empty collection & only type info in XmlElementAttribute
			element.Type = typeof(StringCollection);
			Serialize(container, overrides);
			AssertEquals (Infoset("<StringCollectionContainer xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><Messages><string>hello</string></Messages></StringCollectionContainer>"), WriterText);
			
			// non-empty collection & only type info in XmlElementAttribute
			element.Type = typeof(string);
			Serialize(container, overrides);
			AssertEquals(Infoset("<StringCollectionContainer xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><Messages>hello</Messages></StringCollectionContainer>"), WriterText);
			
			// two elements
			container.Messages.Add("goodbye");
			element.Type = null;
			Serialize(container, overrides);
			AssertEquals(Infoset("<StringCollectionContainer xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><Messages>hello</Messages><Messages>goodbye</Messages></StringCollectionContainer>"), WriterText);
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:42,代码来源:XmlSerializerTests.cs


示例12: BuildHeadersReflectionMembers

		XmlReflectionMember [] BuildHeadersReflectionMembers (HeaderInfo[] headers)
		{
			XmlReflectionMember [] mems = new XmlReflectionMember [headers.Length];

			for (int n=0; n<headers.Length; n++)
			{
				HeaderInfo header = headers [n];
				
				XmlReflectionMember m = new XmlReflectionMember ();
				m.IsReturnValue = false;
				m.MemberName = header.HeaderType.Name;
				m.MemberType = header.HeaderType;

				// MS.NET reflects header classes in a weird way. The root element
				// name is the CLR class name unless it is specified in an XmlRootAttribute.
				// The usual is to use the xml type name by default, but not in this case.
				
				XmlAttributes ats = new XmlAttributes (header.HeaderType);
				if (ats.XmlRoot != null) {
					XmlElementAttribute xe = new XmlElementAttribute ();
					xe.ElementName = ats.XmlRoot.ElementName;
					xe.Namespace = ats.XmlRoot.Namespace;
					m.XmlAttributes = new XmlAttributes ();
					m.XmlAttributes.XmlElements.Add (xe);
				}
				
				mems [n] = m;
			}
			return mems;
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:30,代码来源:Methods.cs


示例13: TestSerializeXmlElementAttribute

		public void TestSerializeXmlElementAttribute()
		{
			
			
			XmlAttributeOverrides overrides = new XmlAttributeOverrides();
			XmlAttributes attr = new XmlAttributes();
			XmlElementAttribute element = new XmlElementAttribute();
			attr.XmlElements.Add(element);
			overrides.Add(typeof(SimpleClass), "something", attr);
			
			// null
			SimpleClass simple = new SimpleClass();;
			Serialize(simple, overrides);
			AssertEquals(Infoset("<SimpleClass xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />"), WriterText);
			
			// not null
			simple.something = "hello";
			Serialize(simple, overrides);
			AssertEquals (Infoset("<SimpleClass xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><something>hello</something></SimpleClass>"), WriterText);
			
			//ElementName
			element.ElementName = "saying";
			Serialize(simple, overrides);
			AssertEquals (Infoset("<SimpleClass xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><saying>hello</saying></SimpleClass>"), WriterText);
			
			//IsNullable
			element.IsNullable = false;
			simple.something = null;
			Serialize(simple, overrides);
			AssertEquals(Infoset("<SimpleClass xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />"),WriterText);
			
			element.IsNullable = true;
			simple.something = null;
			Serialize(simple, overrides);
			AssertEquals (Infoset("<SimpleClass xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><saying xsi:nil='true' /></SimpleClass>"), WriterText);
			
			//Namespace
			element.ElementName = null;
			element.IsNullable = false;
			element.Namespace = "some:urn";
			simple.something = "hello";
			Serialize(simple, overrides);
			AssertEquals (Infoset("<SimpleClass xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><something xmlns='some:urn'>hello</something></SimpleClass>"), WriterText);
			
			//FIXME DataType
			//FIXME Form
			//FIXME Type
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:48,代码来源:XmlSerializerTests.cs


示例14: BuildRequestReflectionMembers

		XmlReflectionMember [] BuildRequestReflectionMembers (XmlElementAttribute optional_ns)
		{
			ParameterInfo [] input = MethodInfo.InParameters;
			XmlReflectionMember [] in_members = new XmlReflectionMember [input.Length];

			for (int i = 0; i < input.Length; i++)
			{
				XmlReflectionMember m = new XmlReflectionMember ();
				m.IsReturnValue = false;
				m.MemberName = input [i].Name;
				m.MemberType = input [i].ParameterType;

				m.XmlAttributes = new XmlAttributes (input[i]);
				m.SoapAttributes = new SoapAttributes (input[i]);

				if (m.MemberType.IsByRef)
					m.MemberType = m.MemberType.GetElementType ();
				if (optional_ns != null)
					m.XmlAttributes.XmlElements.Add (optional_ns);
				in_members [i] = m;
			}
			return in_members;
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:23,代码来源:Methods.cs


示例15: BuildResponseReflectionMembers

		XmlReflectionMember [] BuildResponseReflectionMembers (XmlElementAttribute optional_ns)
		{
			ParameterInfo [] output = MethodInfo.OutParameters;
			bool has_return_value = !(OneWay || MethodInfo.ReturnType == typeof (void));
			XmlReflectionMember [] out_members = new XmlReflectionMember [(has_return_value ? 1 : 0) + output.Length];
			XmlReflectionMember m;
			int idx = 0;

			if (has_return_value)
			{
				m = new XmlReflectionMember ();
				m.IsReturnValue = true;
				m.MemberName = Name + "Result";
				m.MemberType = MethodInfo.ReturnType;

				m.XmlAttributes = new XmlAttributes (MethodInfo.ReturnTypeCustomAttributeProvider);
				m.SoapAttributes = new SoapAttributes (MethodInfo.ReturnTypeCustomAttributeProvider);

				if (optional_ns != null)
					m.XmlAttributes.XmlElements.Add (optional_ns);
				idx++;
				out_members [0] = m;
			}
			
			for (int i = 0; i < output.Length; i++)
			{
				m = new XmlReflectionMember ();
				m.IsReturnValue = false;
				m.MemberName = output [i].Name;
				m.MemberType = output [i].ParameterType;
				m.XmlAttributes = new XmlAttributes (output[i]);
				m.SoapAttributes = new SoapAttributes (output[i]);

				if (m.MemberType.IsByRef)
					m.MemberType = m.MemberType.GetElementType ();
				if (optional_ns != null)
					m.XmlAttributes.XmlElements.Add (optional_ns);
				out_members [i + idx] = m;
			}
			return out_members;
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:41,代码来源:Methods.cs


示例16: SupportIXmlSerializableImplicitlyConvertible

		public void SupportIXmlSerializableImplicitlyConvertible ()
		{
			XmlAttributes attrs = new XmlAttributes ();
			XmlElementAttribute attr = new XmlElementAttribute ();
			attr.ElementName = "XmlSerializable";
			attr.Type = typeof (XmlSerializableImplicitConvertible.XmlSerializable);
			attrs.XmlElements.Add (attr);
			XmlAttributeOverrides attrOverrides = new
			XmlAttributeOverrides ();
			attrOverrides.Add (typeof (XmlSerializableImplicitConvertible), "B", attrs);

			XmlSerializableImplicitConvertible x = new XmlSerializableImplicitConvertible ();
			new XmlSerializer (typeof (XmlSerializableImplicitConvertible), attrOverrides).Serialize (TextWriter.Null, x);
		}
开发者ID:frje,项目名称:SharpLang,代码行数:14,代码来源:XmlSerializerTests.cs


示例17: SoapMethodStubInfo

		//
		// Constructor
		//
		public SoapMethodStubInfo (TypeStubInfo typeStub, LogicalMethodInfo source, object kind, XmlReflectionImporter xmlImporter, SoapReflectionImporter soapImporter)
		: base (typeStub, source)
		{
			SoapTypeStubInfo parent = (SoapTypeStubInfo) typeStub;
			XmlElementAttribute optional_ns = null;

			if (kind == null) {
				Use = parent.LogicalType.BindingUse;
				RequestName = "";
				RequestNamespace = "";
				ResponseName = "";
				ResponseNamespace = "";
				ParameterStyle = parent.ParameterStyle;
				SoapBindingStyle = parent.SoapBindingStyle;
				OneWay = false;
// disabled (see bug #332150)
//#if NET_2_0
//				if (parent.Type != source.DeclaringType)
//					Binding = source.DeclaringType.Name + parent.ProtocolName;
//#endif
			}
			else if (kind is SoapDocumentMethodAttribute){
				SoapDocumentMethodAttribute dma = (SoapDocumentMethodAttribute) kind;
				
				Use = dma.Use;
				if (Use == SoapBindingUse.Default) {
					if (parent.SoapBindingStyle == SoapBindingStyle.Document)
						Use = parent.LogicalType.BindingUse;
					else
						Use = SoapBindingUse.Literal;
				}
				
				Action = dma.Action;
				Binding = dma.Binding;
				RequestName = dma.RequestElementName;
				RequestNamespace = dma.RequestNamespace;
				ResponseName = dma.ResponseElementName;
				ResponseNamespace = dma.ResponseNamespace;
				ParameterStyle = dma.ParameterStyle;
				if (ParameterStyle == SoapParameterStyle.Default)
					ParameterStyle = parent.ParameterStyle;
				OneWay = dma.OneWay;
				SoapBindingStyle = SoapBindingStyle.Document;
			} else {
				SoapRpcMethodAttribute rma = (SoapRpcMethodAttribute) kind;
				Use = SoapBindingUse.Encoded;	// RPC always use encoded

				Action = rma.Action;
				if (Action != null && Action.Length == 0)
					Action = null;
				Binding = rma.Binding;
				
				// When using RPC, MS.NET seems to ignore RequestElementName and
				// MessageName, and it always uses the method name
				RequestName = source.Name;
				ResponseName = source.Name + "Response";
//				RequestName = rma.RequestElementName;
//				ResponseName = rma.ResponseElementName;
				RequestNamespace = rma.RequestNamespace;
				ResponseNamespace = rma.ResponseNamespace;
				ParameterStyle = SoapParameterStyle.Wrapped;
				OneWay = rma.OneWay;
				SoapBindingStyle = SoapBindingStyle.Rpc;

				// For RPC calls, make all arguments be part of the empty namespace
				optional_ns = new XmlElementAttribute ();
				optional_ns.Namespace = "";
			}

			if (OneWay){
				if (source.ReturnType != typeof (void))
					throw new Exception ("OneWay methods should not have a return value.");
				if (source.OutParameters.Length != 0)
					throw new Exception ("OneWay methods should not have out/ref parameters.");
			}
			
			BindingInfo binfo = parent.GetBinding (Binding);
			if (binfo == null) throw new InvalidOperationException ("Type '" + parent.Type + "' is missing WebServiceBinding attribute that defines a binding named '" + Binding + "'.");
			
			string serviceNamespace = binfo.Namespace;
				
			if (RequestNamespace == "") RequestNamespace = parent.LogicalType.GetWebServiceNamespace (serviceNamespace, Use);
			if (ResponseNamespace == "") ResponseNamespace = parent.LogicalType.GetWebServiceNamespace (serviceNamespace, Use);
			if (RequestName == "") RequestName = Name;
			if (ResponseName == "")	ResponseName = Name + "Response";
			if (Action == null)
				Action = serviceNamespace.EndsWith("/") ? (serviceNamespace + Name) : (serviceNamespace + "/" + Name);
			
			bool hasWrappingElem = (ParameterStyle == SoapParameterStyle.Wrapped);
			bool writeAccessors = (SoapBindingStyle == SoapBindingStyle.Rpc);
			
			XmlReflectionMember [] in_members = BuildRequestReflectionMembers (optional_ns);
			XmlReflectionMember [] out_members = BuildResponseReflectionMembers (optional_ns);

			if (Use == SoapBindingUse.Literal) {
				xmlImporter.IncludeTypes (source.CustomAttributeProvider);
				InputMembersMapping = xmlImporter.ImportMembersMapping (RequestName, RequestNamespace, in_members, hasWrappingElem);
//.........这里部分代码省略.........
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:101,代码来源:Methods.cs


示例18: DifferentForm

		public void DifferentForm()
		{
			XmlElementAttribute element1 = new XmlElementAttribute("myname");
			element1.Form = System.Xml.Schema.XmlSchemaForm.Qualified;
			XmlElementAttribute element2 = new XmlElementAttribute("myname");
			element2.Form = System.Xml.Schema.XmlSchemaForm.Unqualified;

			atts1.XmlElements.Add(element1);
			atts2.XmlElements.Add(element2);

			ov1.Add(typeof(SerializeMe), atts1);
			ov2.Add(typeof(SerializeMe), atts2);

			ThumbprintHelpers.DifferentThumbprint(ov1, ov2);
		}
开发者ID:zanyants,项目名称:mvp.xml,代码行数:15,代码来源:XmlElementThumbprintTests.cs


示例19: ExportClass_Array

		public void ExportClass_Array ()
		{
			XmlAttributeOverrides overrides = new XmlAttributeOverrides ();
			XmlAttributes attr = new XmlAttributes ();
			XmlElementAttribute element = new XmlElementAttribute ();
			element.ElementName = "saying";
			element.IsNullable = true;
			attr.XmlElements.Add (element);
			overrides.Add (typeof (SimpleClass), "something", attr);

			XmlSchemas schemas = Export (typeof (SimpleClass[]), overrides, "NSSimpleClassArray");
			Assert.AreEqual (1, schemas.Count, "#1");

			StringWriter sw = new StringWriter ();
			schemas[0].Write (sw);

			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
				"<xs:schema xmlns:tns=\"NSSimpleClassArray\" elementFormDefault=\"qualified\" targetNamespace=\"NSSimpleClassArray\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
				"  <xs:element name=\"ArrayOfSimpleClass\" nillable=\"true\" type=\"tns:ArrayOfSimpleClass\" />{0}" +
				"  <xs:complexType name=\"ArrayOfSimpleClass\">{0}" +
				"    <xs:sequence>{0}" +
				"      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"SimpleClass\" nillable=\"true\" type=\"tns:SimpleClass\" />{0}" +
				"    </xs:sequence>{0}" +
				"  </xs:complexType>{0}" +
				"  <xs:complexType name=\"SimpleClass\">{0}" +
				"    <xs:sequence>{0}" +
				"      <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"saying\" nillable=\"true\" type=\"xs:string\" />{0}" +
				"    </xs:sequence>{0}" +
				"  </xs:complexType>{0}" +
				"</xs:schema>", Environment.NewLine), sw.ToString (), "#2");

			schemas = Export (typeof (SimpleClass[]), overrides);
			Assert.AreEqual (1, schemas.Count, "#3");

			sw.GetStringBuilder ().Length = 0;
			schemas[0].Write (sw);

			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
				"<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
				"  <xs:element name=\"ArrayOfSimpleClass\" nillable=\"true\" type=\"ArrayOfSimpleClass\" />{0}" +
				"  <xs:complexType name=\"ArrayOfSimpleClass\">{0}" +
				"    <xs:sequence>{0}" +
				"      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"SimpleClass\" nillable=\"true\" type=\"SimpleClass\" />{0}" +
				"    </xs:sequence>{0}" +
				"  </xs:complexType>{0}" +
				"  <xs:complexType name=\"SimpleClass\">{0}" +
				"    <xs:sequence>{0}" +
				"      <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"saying\" nillable=\"true\" type=\"xs:string\" />{0}" +
				"    </xs:sequence>{0}" +
				"  </xs:complexType>{0}" +
				"</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:54,代码来源:XmlSchemaExporterTests.cs


示例20: Remove

		public void Remove(XmlElementAttribute attribute)
		{
			List.Remove(attribute);
		}
开发者ID:nobled,项目名称:mono,代码行数:4,代码来源:XmlElementAttributes.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Serialization.XmlMapping类代码示例发布时间:2022-05-26
下一篇:
C# Serialization.XmlAttributes类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap