Inheritance: System.Attribute
Esempio n. 1
0
		public void ElementNameDefault ()
		{
			XmlElementAttribute attr = new XmlElementAttribute ();
			Assert.AreEqual (string.Empty, attr.ElementName, "#1");

			attr.ElementName = null;
			Assert.AreEqual (string.Empty, attr.ElementName, "#2");
		}
        /// <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);
        }
        /// <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;
        }
        /// <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);
            }
        }
		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);
		}
Esempio n. 6
0
        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";
        }
		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);
		}
Esempio n. 8
0
        /// <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;
        }
Esempio n. 9
0
        /// <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;
        }
Esempio n. 10
0
        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);
            }
        }
Esempio n. 11
0
        //when we add an element it either needs to be
        private static void AddXMLElement(FileLevelInfo info, XmlElementAttribute xea, ClassSnippet snip, FieldInfo finfo)
        {
            if (xea.Type == null)
              {
            AddSimpleXMLElement(info, xea, snip, finfo);
            return;
              }
              string typeName = xea.Type.ToString();
              string[] ss = typeName.Split(new char[] { '.' });
              typeName = ss[ss.Length - 1];
              string typesuffix = "_t";
              string fromNamespace = getCppNamespace(xea.Namespace);
              string fullName;
              string swigFullName;
              string ename = xea.ElementName;
              if (xea.Type.Namespace == "System")
              {
            if (!info.knownSimpleTypes.ContainsKey(typeName.ToLower()))
            {
              throw new Exception("Unknown system array type : " + typeName);
            }
            fromNamespace = info.nSpace;
            typesuffix = "";
            typeName = (string)info.knownSimpleTypes[typeName.ToLower()];
            fullName = typeName;
            swigFullName = info.nSpace + "::" + typeName;
            if (!info.collections.ContainsKey(typeName)) info.collections.Add(typeName, typeName);
              }
              else if (fromNamespace == info.nSpace)
              {
            if (typeName != snip.type.Name)
            {
              //don't make a class dependent on itself.
              snip.dependencies.Add(typeName);
            }
            fullName = typeName;
            swigFullName = info.nSpace +"::"+typeName;
              }
              else
              {
            fullName = fromNamespace + "::" + typeName;
            swigFullName = fullName;
            if (!info.includes.ContainsKey(fromNamespace)) info.includes.Add(fromNamespace, fullName);
              }
              bool isCollection = false;
              if (info.collections.ContainsKey(typeName))
              {
            snip.declarations += "#ifdef SWIG\n%immutable " + ename + "Vector;\n#endif\n";

            snip.classDeclaration = "#ifdef SWIG\n}\n%template(" + ename + "_c) std::vector<" + swigFullName + typesuffix + "*>;\nnamespace " + info.nSpace + "{\n#endif\n" + snip.classDeclaration;
            snip.declarations += "\tprivate: collectedType < " + fullName + typesuffix+" > " + ename + ";\n";
            snip.declarations += "\tpublic: vector < " + fullName + typesuffix+"* >& "+ename+"Vector;\n";
            if (snip.constructor == null)
            {
              snip.constructor = snip.className + "::" + snip.className + "():\n\t\t";
            }
            else
            {
              snip.constructor += ",\n\t\t";
            }
            snip.constructor += ename + "(\"" + typeName + "\"), "+ename+"Vector(" + ename + ".collection)";

            if (snip.needsChildren != null) snip.needsChildren += " && ";
            snip.needsChildren += ename + ".size() == 0";

            isCollection = true;
              }
              else
              {
            snip.declarations += "#ifdef SWIG\n%immutable " + ename + ";\n#endif\n";
            snip.declarations += "\t" + fullName + typesuffix +" " + ename + ";\n";
              }

              snip.toXml += "\t" + ename + ".toXml(pEm, true, aIgnoreValid);\n";
              string nodeName = "pNode->FirstChildElement(\"" + ename + "\")";
              if (ename == snip.type.Name || isCollection) nodeName = "pNode";
              snip.fromXml += "\t" + ename + ".fromXml(" + nodeName + ");\n";
        }
        static internal XmlReflectionMember GetXmlReflectionMember(XmlName memberName, XmlName elementName, string ns, Type type, MemberInfo additionalAttributesProvider, bool isMultiple, bool isWrapped)
        {
            XmlReflectionMember member = new XmlReflectionMember();
            member.MemberName = (memberName ?? elementName).DecodedName;
            member.MemberType = type;
            if (member.MemberType.IsByRef)
                member.MemberType = member.MemberType.GetElementType();
            if (isMultiple)
                member.MemberType = member.MemberType.MakeArrayType();
            if (additionalAttributesProvider != null)
            {
                member.XmlAttributes = XmlAttributesHelper.CreateXmlAttributes(additionalAttributesProvider);
            }

            if (member.XmlAttributes == null)
                member.XmlAttributes = new XmlAttributes();
            else
            {
                Type invalidAttributeType = null;
                if (member.XmlAttributes.XmlAttribute != null)
                    invalidAttributeType = typeof(XmlAttributeAttribute);
                else if (member.XmlAttributes.XmlAnyAttribute != null && !isWrapped)
                    invalidAttributeType = typeof(XmlAnyAttributeAttribute);
                else if (member.XmlAttributes.XmlChoiceIdentifier != null)
                    invalidAttributeType = typeof(XmlChoiceIdentifierAttribute);
                else if (member.XmlAttributes.XmlIgnore)
                    invalidAttributeType = typeof(XmlIgnoreAttribute);
                else if (member.XmlAttributes.Xmlns)
                    invalidAttributeType = typeof(XmlNamespaceDeclarationsAttribute);
                else if (member.XmlAttributes.XmlText != null)
                    invalidAttributeType = typeof(XmlTextAttribute);
                else if (member.XmlAttributes.XmlEnum != null)
                    invalidAttributeType = typeof(XmlEnumAttribute);
                if (invalidAttributeType != null)
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(isWrapped ? SR.SFxInvalidXmlAttributeInWrapped : SR.SFxInvalidXmlAttributeInBare, invalidAttributeType, elementName.DecodedName)));
                if (member.XmlAttributes.XmlArray != null && isMultiple)
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFxXmlArrayNotAllowedForMultiple, elementName.DecodedName, ns)));
            }


            bool isArray = member.MemberType.IsArray;
            if ((isArray && !isMultiple && member.MemberType != typeof(byte[])) ||
                (!isArray && typeof(IEnumerable).IsAssignableFrom(member.MemberType) && member.MemberType != typeof(string) && !typeof(XmlNode).IsAssignableFrom(member.MemberType) && !typeof(IXmlSerializable).IsAssignableFrom(member.MemberType)))
            {
                if (member.XmlAttributes.XmlArray != null)
                {
                    if (member.XmlAttributes.XmlArray.ElementName == String.Empty)
                        member.XmlAttributes.XmlArray.ElementName = elementName.DecodedName;
                    if (member.XmlAttributes.XmlArray.Namespace == null)
                        member.XmlAttributes.XmlArray.Namespace = ns;
                }
                else if (HasNoXmlParameterAttributes(member.XmlAttributes))
                {
                    member.XmlAttributes.XmlArray = new XmlArrayAttribute();
                    member.XmlAttributes.XmlArray.ElementName = elementName.DecodedName;
                    member.XmlAttributes.XmlArray.Namespace = ns;
                }
            }
            else
            {
                if (member.XmlAttributes.XmlElements == null || member.XmlAttributes.XmlElements.Count == 0)
                {
                    if (HasNoXmlParameterAttributes(member.XmlAttributes))
                    {
                        XmlElementAttribute elementAttribute = new XmlElementAttribute();
                        elementAttribute.ElementName = elementName.DecodedName;
                        elementAttribute.Namespace = ns;
                        member.XmlAttributes.XmlElements.Add(elementAttribute);
                    }
                }
                else
                {
                    foreach (XmlElementAttribute elementAttribute in member.XmlAttributes.XmlElements)
                    {
                        if (elementAttribute.ElementName == String.Empty)
                            elementAttribute.ElementName = elementName.DecodedName;
                        if (elementAttribute.Namespace == null)
                            elementAttribute.Namespace = ns;
                    }
                }
            }

            return member;
        }
Esempio n. 13
0
 /// <summary>Inserts an <see cref="T:System.Xml.Serialization.XmlElementAttribute" /> into the collection.</summary>
 /// <param name="index">The zero-based index where the member is added. </param>
 /// <param name="attribute">The <see cref="T:System.Xml.Serialization.XmlElementAttribute" /> to insert. </param>
 public void Insert(int index, XmlElementAttribute attribute)
 {
     base.List.Insert(index, attribute);
 }
Esempio n. 14
0
 /// <summary>Adds an <see cref="T:System.Xml.Serialization.XmlElementAttribute" /> to the collection.</summary>
 /// <returns>The zero-based index of the newly added item.</returns>
 /// <param name="attribute">The <see cref="T:System.Xml.Serialization.XmlElementAttribute" /> to add. </param>
 public int Add(XmlElementAttribute attribute)
 {
     return(base.List.Add(attribute));
 }
Esempio n. 15
0
		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;
		}
Esempio n. 16
0
		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;
		}
Esempio n. 17
0
		public int Add (XmlElementAttribute attribute)
		{
			return (List as IList).Add (attribute);
		}
Esempio n. 18
0
		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);
		}
Esempio n. 19
0
 /// <summary>Gets a value that specifies whether the collection contains the specified object.</summary>
 /// <returns>true, if the object exists in the collection; otherwise, false.</returns>
 /// <param name="attribute">The <see cref="T:System.Xml.Serialization.XmlElementAttribute" />  in question. </param>
 public bool Contains(XmlElementAttribute attribute)
 {
     return(base.List.Contains(attribute));
 }
		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
		}
		public void DifferentMemberName()
		{
			XmlElementAttribute element1 = new XmlElementAttribute("myname");
			XmlElementAttribute element2 = new XmlElementAttribute("myname");

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

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

			ThumbprintHelpers.DifferentThumbprint(ov1, ov2);
		}
		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);
		}
Esempio n. 23
0
 /// <summary>Gets the index of the specified <see cref="T:System.Xml.Serialization.XmlElementAttribute" />.</summary>
 /// <returns>The zero-based index of the <see cref="T:System.Xml.Serialization.XmlElementAttribute" />.</returns>
 /// <param name="attribute">The <see cref="T:System.Xml.Serialization.XmlElementAttribute" />  you are interested in.</param>
 public int IndexOf(XmlElementAttribute attribute)
 {
     return(base.List.IndexOf(attribute));
 }
Esempio n. 24
0
 /// <include file='doc\XmlElementAttributes.uex' path='docs/doc[@for="XmlElementAttributes.Add"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public int Add(XmlElementAttribute attribute)
 {
     return List.Add(attribute);
 }
Esempio n. 25
0
		public int IndexOf(XmlElementAttribute attribute)
		{
			return List.IndexOf(attribute);
		}
Esempio n. 26
0
		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");
		}
Esempio n. 27
0
		public void Remove(XmlElementAttribute attribute)
		{
			List.Remove(attribute);
		}
Esempio n. 28
0
		//
		// 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);
				OutputMembersMapping = xmlImporter.ImportMembersMapping (ResponseName, ResponseNamespace, out_members, hasWrappingElem);
			}
			else {
				soapImporter.IncludeTypes (source.CustomAttributeProvider);
				InputMembersMapping = soapImporter.ImportMembersMapping (RequestName, RequestNamespace, in_members, hasWrappingElem, writeAccessors);
				OutputMembersMapping = soapImporter.ImportMembersMapping (ResponseName, ResponseNamespace, out_members, hasWrappingElem, writeAccessors);
			}

			InputMembersMapping.SetKey(RequestName);
			OutputMembersMapping.SetKey(ResponseName);

			requestSerializerId = parent.RegisterSerializer (InputMembersMapping);
			responseSerializerId = parent.RegisterSerializer (OutputMembersMapping);

			object[] o = source.GetCustomAttributes (typeof (SoapHeaderAttribute));
			ArrayList allHeaderList = new ArrayList (o.Length);
			ArrayList inHeaderList = new ArrayList (o.Length);
			ArrayList outHeaderList = new ArrayList (o.Length);
			ArrayList faultHeaderList = new ArrayList ();
			
			SoapHeaderDirection unknownHeaderDirections = (SoapHeaderDirection)0;
			
			for (int i = 0; i < o.Length; i++) {
				SoapHeaderAttribute att = (SoapHeaderAttribute) o[i];
				MemberInfo[] mems = source.DeclaringType.GetMember (att.MemberName);
				if (mems.Length == 0) throw new InvalidOperationException ("Member " + att.MemberName + " not found in class " + source.DeclaringType.FullName + ".");
				
				HeaderInfo header = new HeaderInfo (mems[0], att);
				allHeaderList.Add (header);
				if (!header.Custom) {
					if ((header.Direction & SoapHeaderDirection.In) != 0)
						inHeaderList.Add (header);
					if ((header.Direction & SoapHeaderDirection.Out) != 0)
						outHeaderList.Add (header);
					if ((header.Direction & SoapHeaderDirection.Fault) != 0)
						faultHeaderList.Add (header);
				} else
					unknownHeaderDirections |= header.Direction;
			}
			
			Headers = (HeaderInfo[]) allHeaderList.ToArray (typeof(HeaderInfo));

			if (inHeaderList.Count > 0 || (unknownHeaderDirections & SoapHeaderDirection.In) != 0) {
				InHeaders = (HeaderInfo[]) inHeaderList.ToArray (typeof(HeaderInfo));
				XmlReflectionMember[] members = BuildHeadersReflectionMembers (InHeaders);
				
				if (Use == SoapBindingUse.Literal)
					InputHeaderMembersMapping = xmlImporter.ImportMembersMapping ("", RequestNamespace, members, false);
				else
					InputHeaderMembersMapping = soapImporter.ImportMembersMapping ("", RequestNamespace, members, false, false);
				
				InputHeaderMembersMapping.SetKey(RequestName + ":InHeaders");
				
				requestHeadersSerializerId = parent.RegisterSerializer (InputHeaderMembersMapping);
			}
			
			if (outHeaderList.Count > 0 || (unknownHeaderDirections & SoapHeaderDirection.Out) != 0) {
				OutHeaders = (HeaderInfo[]) outHeaderList.ToArray (typeof(HeaderInfo));
				XmlReflectionMember[] members = BuildHeadersReflectionMembers (OutHeaders);
				
				if (Use == SoapBindingUse.Literal)
					OutputHeaderMembersMapping = xmlImporter.ImportMembersMapping ("", RequestNamespace, members, false);
				else
					OutputHeaderMembersMapping = soapImporter.ImportMembersMapping ("", RequestNamespace, members, false, false);

				OutputHeaderMembersMapping.SetKey(ResponseName + ":OutHeaders");

				responseHeadersSerializerId = parent.RegisterSerializer (OutputHeaderMembersMapping);
			}
			
			if (faultHeaderList.Count > 0 || (unknownHeaderDirections & SoapHeaderDirection.Fault) != 0) {
				FaultHeaders = (HeaderInfo[]) faultHeaderList.ToArray (typeof(HeaderInfo));
				XmlReflectionMember[] members = BuildHeadersReflectionMembers (FaultHeaders);
				
				if (Use == SoapBindingUse.Literal)
					FaultHeaderMembersMapping = xmlImporter.ImportMembersMapping ("", RequestNamespace, members, false);
				else
					FaultHeaderMembersMapping = soapImporter.ImportMembersMapping ("", RequestNamespace, members, false, false);
				
				faultHeadersSerializerId = parent.RegisterSerializer (FaultHeaderMembersMapping);
			}
			
			SoapExtensions = SoapExtension.GetMethodExtensions (source);
		}
Esempio n. 29
0
 public int Add(XmlElementAttribute attribute)
 {
     return((List as IList).Add(attribute));
 }
Esempio n. 30
0
		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;
		}
 public void Remove(System.Xml.Serialization.XmlElementAttribute attribute)
 {
 }
Esempio n. 32
0
        public static T FromXML <T>(XmlNode Xml, IFormatProvider Provider) where T : new()
        {
            Type TypeEntity = typeof(T);

            T Entity = new T();


            //List<> of Types
            if (TypeEntity.IsGenericType && typeof(System.Collections.IList).IsAssignableFrom(TypeEntity.GetGenericTypeDefinition()))
            {
                foreach (XmlNode node in Xml.ChildNodes)
                {
                    object ret = node.InnerXml;
                    if (node.NodeType != XmlNodeType.XmlDeclaration)
                    {
                        Type UnderlyingType = TypeEntity.GetGenericArguments()[0];

                        Type[] BasicTypes = { typeof(String), typeof(Int16), typeof(Int32), typeof(Int64), typeof(Boolean), typeof(DateTime), typeof(System.Char), typeof(System.Decimal), typeof(System.Double), typeof(System.Single), typeof(System.TimeSpan), typeof(System.Byte) };


                        //If not a basic Type , try to deep more in the dom tree deserializing the inner XML Value
                        if (BasicTypes.SingleOrDefault((t) => { return(t == UnderlyingType); }) == null)
                        {
                            //Otherwise of arrays convert to XML to send
                            var fromXMLMethods = typeof(Gale.Serialization).GetMethods(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
                            System.Reflection.MethodInfo fromXMLMethodInfo = fromXMLMethods.FirstOrDefault(mi => mi.Name == "FromXML" && mi.GetGenericArguments().Count() == 1 && mi.GetParameters()[0].ParameterType == typeof(XmlNode));

                            System.Reflection.MethodInfo method = fromXMLMethodInfo.MakeGenericMethod(new Type[] { UnderlyingType });
                            ret = method.Invoke(null, new object[] { node });
                        }

                        (Entity as System.Collections.IList).Add(Convert.ChangeType(ret, UnderlyingType));
                    }
                }
                return((T)Entity);
            }

            List <PropertyInfo> setterProperties = (from PropertyInfo p in TypeEntity.GetProperties() where p.GetIndexParameters().Count() == 0 select p).ToList();

            //Delegate
            Action <PropertyInfo, object> setValue = (Property, Value) =>
            {
                try
                {
                    Property.SetValue(Entity, Value, null);
                }
                catch
                {
                    throw new Gale.Exception.GaleException("InvalidSetValueInXMLDeserialization", Value.ToString(), Property.Name, Property.PropertyType.ToString());
                }
            };

            //For Each
            setterProperties.ForEach((prop) =>
            {
                if (object.ReferenceEquals(prop.DeclaringType, TypeEntity))
                {
                    System.Xml.Serialization.XmlAttributeAttribute customAttribute = (System.Xml.Serialization.XmlAttributeAttribute)prop.GetCustomAttributes(typeof(System.Xml.Serialization.XmlAttributeAttribute), false).FirstOrDefault();
                    Type propertyType          = prop.PropertyType;
                    string nodeValue           = null;
                    System.Xml.XmlNode noderef = null;

                    if (customAttribute != null)
                    {
                        XmlAttribute attrib = Xml.Attributes[customAttribute.AttributeName];
                        if (attrib != null)
                        {
                            nodeValue = attrib.InnerXml;
                        }
                    }
                    else
                    {
                        System.Xml.Serialization.XmlElementAttribute xmlattrib = (System.Xml.Serialization.XmlElementAttribute)prop.GetCustomAttributes(typeof(System.Xml.Serialization.XmlElementAttribute), false).FirstOrDefault();
                        XmlNode propertyNode = Xml.SelectSingleNode((xmlattrib != null) ? xmlattrib.ElementName : prop.Name);
                        if (propertyNode != null)
                        {
                            noderef   = propertyNode;
                            nodeValue = propertyNode.InnerXml;
                        }
                    }

                    if (nodeValue != null && nodeValue != String.Empty)
                    {
                        if (Type.Equals(propertyType, typeof(decimal)))
                        {
                            setValue(prop, System.Convert.ToDecimal(nodeValue, Provider));
                        }
                        else if (Type.Equals(propertyType, typeof(double)))
                        {
                            setValue(prop, System.Convert.ToDouble(nodeValue, Provider));
                        }
                        else if (Type.Equals(propertyType, typeof(Int16)))
                        {
                            setValue(prop, System.Convert.ToInt16(nodeValue, Provider));
                        }
                        else if (Type.Equals(propertyType, typeof(Int32)))
                        {
                            setValue(prop, System.Convert.ToInt32(nodeValue, Provider));
                        }
                        else if (Type.Equals(propertyType, typeof(Int64)))
                        {
                            setValue(prop, System.Convert.ToInt64(nodeValue, Provider));
                        }
                        else if (Type.Equals(propertyType, typeof(bool)))
                        {
                            setValue(prop, System.Convert.ToBoolean(nodeValue, Provider));
                        }
                        else if (Type.Equals(propertyType, typeof(DateTime)))
                        {
                            setValue(prop, System.Convert.ToDateTime(nodeValue, Provider));
                        }
                        else if (Type.Equals(propertyType, typeof(string)))
                        {
                            setValue(prop, System.Convert.ToString(nodeValue, Provider));
                        }
                        else if (propertyType.IsArray)
                        {
                            if (nodeValue != string.Empty)
                            {
                                Type UnderlyingType = propertyType.GetElementType();  //Array or a Generic List (Almost the same things)
                                // Creates and initializes a new Array of type Int32.
                                Array typedArray = Array.CreateInstance(UnderlyingType, noderef.ChildNodes.Count);

                                int arrayIndex = 0;
                                foreach (XmlNode node in noderef.ChildNodes)
                                {
                                    object ret = node.InnerXml;
                                    if (node.NodeType != XmlNodeType.XmlDeclaration)
                                    {
                                        //If not a basic Type , try to deep more in the dom tree deserializing the inner XML Value
                                        Type[] BasicTypes = { typeof(String), typeof(Int16), typeof(Int32), typeof(Int64), typeof(Boolean), typeof(DateTime), typeof(System.Char), typeof(System.Decimal), typeof(System.Double), typeof(System.Single), typeof(System.TimeSpan), typeof(System.Byte) };
                                        if (BasicTypes.SingleOrDefault((t) => { return(t == UnderlyingType); }) == null)
                                        {
                                            //Otherwise of arrays convert to XML to send
                                            var fromXMLMethods = typeof(Gale.Serialization).GetMethods(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
                                            System.Reflection.MethodInfo fromXMLMethodInfo = fromXMLMethods.FirstOrDefault(mi => mi.Name == "FromXML" && mi.GetGenericArguments().Count() == 1 && mi.GetParameters()[0].ParameterType == typeof(XmlNode));

                                            System.Reflection.MethodInfo method = fromXMLMethodInfo.MakeGenericMethod(new Type[] { UnderlyingType });
                                            ret = method.Invoke(null, new object[] { node });
                                        }

                                        typedArray.SetValue(Convert.ChangeType(ret, UnderlyingType), arrayIndex);
                                    }
                                    arrayIndex++;
                                }

                                setValue(prop, typedArray);
                            }
                        }
                        else if (propertyType.IsGenericType)
                        {
                            //If a Parameter Type is Nullable, create the nullable type dinamycally and set it's value
                            Type UnderlyingType    = propertyType.GetGenericArguments()[0];
                            Type GenericDefinition = propertyType.GetGenericTypeDefinition();

                            Type GenericType = GenericDefinition.MakeGenericType(new Type[] { UnderlyingType });

                            object value = null;
                            if (nodeValue != string.Empty)
                            {
                                if (GenericDefinition == typeof(System.Nullable <>))
                                {
                                    value = Convert.ChangeType(nodeValue, UnderlyingType);
                                }
                                else
                                {
                                    //Complex Node Type, (Maybe it's a List of Other Complex Type and go on in the deepest level
                                    //So call the fromXML itself, again and again

                                    //Otherwise of arrays convert to XML to send
                                    var fromXMLMethods = typeof(Gale.Serialization).GetMethods(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
                                    System.Reflection.MethodInfo fromXMLMethodInfo = fromXMLMethods.FirstOrDefault(mi => mi.Name == "FromXML" && mi.GetGenericArguments().Count() == 1 && mi.GetParameters()[0].ParameterType == typeof(XmlNode));

                                    System.Reflection.MethodInfo method = fromXMLMethodInfo.MakeGenericMethod(new Type[] { GenericType });

                                    value = method.Invoke(null, new object[] { noderef });
                                }
                                setValue(prop, Activator.CreateInstance(GenericType, new object[] { value }));
                            }
                        }
                        else
                        {
                            try
                            {
                                //Its a more complex type ( not generic but yes a object with properties and setter's)
                                if (noderef.ChildNodes.Count > 0)
                                {
                                    //Otherwise of arrays convert to XML to send
                                    var fromXMLMethods = typeof(Gale.Serialization).GetMethods(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
                                    System.Reflection.MethodInfo fromXMLMethodInfo = fromXMLMethods.FirstOrDefault(mi => mi.Name == "FromXML" && mi.GetGenericArguments().Count() == 1 && mi.GetParameters()[0].ParameterType == typeof(XmlNode));

                                    System.Reflection.MethodInfo method = fromXMLMethodInfo.MakeGenericMethod(new Type[] { propertyType });

                                    var value = method.Invoke(null, new object[] { noderef });

                                    setValue(prop, Convert.ChangeType(value, propertyType));  //try to set into the variable anyways , if throw error then throw invalid cast exception
                                }
                                else
                                {
                                    setValue(prop, Convert.ChangeType(nodeValue, propertyType));  //try to set into the variable anyways , if throw error then throw invalid cast exception
                                }
                            }
                            catch
                            {
                                //TODO: Perform this Section, To Support Non Primitive Object Type
                                throw new Gale.Exception.GaleException("InvalidCastInXMLDeserialization", prop.Name);
                            }
                        }
                    }
                }
            });

            return((T)(Entity));
        }
Esempio n. 33
0
 /// <summary>Removes the specified object from the collection.</summary>
 /// <param name="attribute">The <see cref="T:System.Xml.Serialization.XmlElementAttribute" /> to remove from the collection. </param>
 public void Remove(XmlElementAttribute attribute)
 {
     base.List.Remove(attribute);
 }
		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);
		}
		public void DifferentDataTypes()
		{
			XmlElementAttribute element1 = new XmlElementAttribute();
			element1.DataType = "typeone";
			XmlElementAttribute element2 = new XmlElementAttribute();
			element2.DataType = "typetwo";

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

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

			ThumbprintHelpers.DifferentThumbprint(ov1, ov2);
		}
Esempio n. 36
0
		public bool Contains(XmlElementAttribute attribute)
		{
			return List.Contains(attribute);	
		}
 public bool Contains(System.Xml.Serialization.XmlElementAttribute attribute)
 {
     throw null;
 }
Esempio n. 38
0
		public void Insert(int index, XmlElementAttribute attribute)
		{
			List.Insert(index, attribute);
		}
 public int IndexOf(System.Xml.Serialization.XmlElementAttribute attribute)
 {
     throw null;
 }
Esempio n. 40
0
		public void CopyTo(XmlElementAttribute[] array,int index)
		{
			List.CopyTo(array, index);
		}
 public void Insert(int index, System.Xml.Serialization.XmlElementAttribute attribute)
 {
 }