// ------------------------------------------------------------------------------ // <auto-generated> // Generated by Xsd2Code. Version 2.8.2.29599 // <NameSpace>Xsd2Code.TestUnit</NameSpace><Collection>List</Collection><codeType>CSharp</codeType><EnableDataBinding>False</EnableDataBinding><HidePrivateFieldInIDE>True</HidePrivateFieldInIDE><EnableSummaryComment>True</EnableSummaryComment><IncludeSerializeMethod>True</IncludeSerializeMethod><GenerateCloneMethod>False</GenerateCloneMethod><GenerateDataContracts>False</GenerateDataContracts><CodeBaseTag>Net20</CodeBaseTag><SerializeMethodName>Serialize</SerializeMethodName><DeserializeMethodName>Deserialize</DeserializeMethodName><SaveToFileMethodName>SaveToFile</SaveToFileMethodName><LoadFromFileMethodName>LoadFromFile</LoadFromFileMethodName><GenerateXMLAttributes>False</GenerateXMLAttributes><AutomaticProperties>False</AutomaticProperties><DisableDebug>False</DisableDebug><CustomUsings></CustomUsings> // <auto-generated> // ------------------------------------------------------------------------------ namespace Xsd2Code.TestUnit { using System; using System.Diagnostics; using System.Xml.Serialization; using System.Collections; using System.Xml.Schema; using System.ComponentModel; using System.IO; using System.Collections.Generic; /// <summary> /// The root element that wraps up all UIElements into an array that's consumed by KAF. /// </summary> public partial class ArrayOfMyElement { [EditorBrowsable(EditorBrowsableState.Never)] private List<MyElement> myElementField; /// <summary> /// .ctor class constructor /// </summary> public ArrayOfMyElement() { if ((this.myElementField == null)) { this.myElementField = new List<MyElement>(); } } public List<MyElement> MyElement { get { return this.myElementField; } set { this.myElementField = value; } } /// <summary> /// Serializes current ArrayOfMyElement object into an XML document /// </summary> // <returns>string XML value</returns> public virtual string Serialize() { System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(this.GetType()); System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); xmlSerializer.Serialize(memoryStream, this); memoryStream.Seek(0, System.IO.SeekOrigin.Begin); System.IO.StreamReader streamReader = new System.IO.StreamReader(memoryStream); return streamReader.ReadToEnd(); } /// <summary> /// Deserializes workflow markup into an ArrayOfMyElement object /// </summary> // <param name="xml">string workflow markup to deserialize</param> // <param name="obj">Output ArrayOfMyElement object</param> // <param name="exception">output Exception value if deserialize failed</param> // <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool Deserialize(string xml, out ArrayOfMyElement obj, out System.Exception exception) { exception = null; obj = null; try { System.IO.StringReader stringReader = new System.IO.StringReader(xml); System.Xml.XmlTextReader xmlTextReader = new System.Xml.XmlTextReader(stringReader); System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(ArrayOfMyElement)); obj = ((ArrayOfMyElement)(xmlSerializer.Deserialize(xmlTextReader))); return true; } catch (System.Exception ex) { exception = ex; return false; } } /// <summary> /// Serializes current ArrayOfMyElement object into file /// </summary> // <param name="fileName">full path of outupt xml file</param> // <param name="exception">output Exception value if failed</param> // <returns>true if can serialize and save into file; otherwise, false</returns> public virtual bool SaveToFile(string fileName, out System.Exception exception) { exception = null; try { string xmlString = Serialize(); System.IO.FileInfo xmlFile = new System.IO.FileInfo(fileName); System.IO.StreamWriter streamWriter = xmlFile.CreateText(); streamWriter.WriteLine(xmlString); streamWriter.Close(); return true; } catch (System.Exception e) { exception = e; return false; } } /// <summary> /// Deserializes workflow markup from file into an ArrayOfMyElement object /// </summary> // <param name="xml">string workflow markup to deserialize</param> // <param name="obj">Output ArrayOfMyElement object</param> // <param name="exception">output Exception value if deserialize failed</param> // <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool LoadFromFile(string fileName, out ArrayOfMyElement obj, out System.Exception exception) { exception = null; obj = null; try { System.IO.FileStream file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); System.IO.StreamReader sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return Deserialize(xmlString, out obj, out exception); } catch (System.Exception ex) { exception = ex; return false; } } } /// <summary> /// Represents a generic object in the user interface such as a button or text box. /// </summary> public partial class MyElement { [EditorBrowsable(EditorBrowsableState.Never)] private string nameField; [EditorBrowsable(EditorBrowsableState.Never)] private List<NameValuePair> attributeListsField; /// <summary> /// .ctor class constructor /// </summary> public MyElement() { if ((this.attributeListsField == null)) { this.attributeListsField = new List<NameValuePair>(); } } public string Name { get { return this.nameField; } set { this.nameField = value; } } [System.Xml.Serialization.XmlArrayItemAttribute("ArrayOfNameValuePair", IsNullable = false)] [System.Xml.Serialization.XmlArrayItemAttribute("NameValuePair", IsNullable = false, NestingLevel = 1)] public List<NameValuePair> AttributeLists { get { return this.attributeListsField; } set { this.attributeListsField = value; } } /// <summary> /// Serializes current MyElement object into an XML document /// </summary> // <returns>string XML value</returns> public virtual string Serialize() { System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(this.GetType()); System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); xmlSerializer.Serialize(memoryStream, this); memoryStream.Seek(0, System.IO.SeekOrigin.Begin); System.IO.StreamReader streamReader = new System.IO.StreamReader(memoryStream); return streamReader.ReadToEnd(); } /// <summary> /// Deserializes workflow markup into an MyElement object /// </summary> // <param name="xml">string workflow markup to deserialize</param> // <param name="obj">Output MyElement object</param> // <param name="exception">output Exception value if deserialize failed</param> // <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool Deserialize(string xml, out MyElement obj, out System.Exception exception) { exception = null; obj = null; try { System.IO.StringReader stringReader = new System.IO.StringReader(xml); System.Xml.XmlTextReader xmlTextReader = new System.Xml.XmlTextReader(stringReader); System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(MyElement)); obj = ((MyElement)(xmlSerializer.Deserialize(xmlTextReader))); return true; } catch (System.Exception ex) { exception = ex; return false; } } /// <summary> /// Serializes current MyElement object into file /// </summary> // <param name="fileName">full path of outupt xml file</param> // <param name="exception">output Exception value if failed</param> // <returns>true if can serialize and save into file; otherwise, false</returns> public virtual bool SaveToFile(string fileName, out System.Exception exception) { exception = null; try { string xmlString = Serialize(); System.IO.FileInfo xmlFile = new System.IO.FileInfo(fileName); System.IO.StreamWriter streamWriter = xmlFile.CreateText(); streamWriter.WriteLine(xmlString); streamWriter.Close(); return true; } catch (System.Exception e) { exception = e; return false; } } /// <summary> /// Deserializes workflow markup from file into an MyElement object /// </summary> // <param name="xml">string workflow markup to deserialize</param> // <param name="obj">Output MyElement object</param> // <param name="exception">output Exception value if deserialize failed</param> // <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool LoadFromFile(string fileName, out MyElement obj, out System.Exception exception) { exception = null; obj = null; try { System.IO.FileStream file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); System.IO.StreamReader sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return Deserialize(xmlString, out obj, out exception); } catch (System.Exception ex) { exception = ex; return false; } } } /// <summary> /// Repro /// </summary> public partial class NameValuePair { [EditorBrowsable(EditorBrowsableState.Never)] private string nameField; [EditorBrowsable(EditorBrowsableState.Never)] private string valueField; public string Name { get { return this.nameField; } set { this.nameField = value; } } public string Value { get { return this.valueField; } set { this.valueField = value; } } /// <summary> /// Serializes current NameValuePair object into an XML document /// </summary> // <returns>string XML value</returns> public virtual string Serialize() { System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(this.GetType()); System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); xmlSerializer.Serialize(memoryStream, this); memoryStream.Seek(0, System.IO.SeekOrigin.Begin); System.IO.StreamReader streamReader = new System.IO.StreamReader(memoryStream); return streamReader.ReadToEnd(); } /// <summary> /// Deserializes workflow markup into an NameValuePair object /// </summary> // <param name="xml">string workflow markup to deserialize</param> // <param name="obj">Output NameValuePair object</param> // <param name="exception">output Exception value if deserialize failed</param> // <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool Deserialize(string xml, out NameValuePair obj, out System.Exception exception) { exception = null; obj = null; try { System.IO.StringReader stringReader = new System.IO.StringReader(xml); System.Xml.XmlTextReader xmlTextReader = new System.Xml.XmlTextReader(stringReader); System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(NameValuePair)); obj = ((NameValuePair)(xmlSerializer.Deserialize(xmlTextReader))); return true; } catch (System.Exception ex) { exception = ex; return false; } } /// <summary> /// Serializes current NameValuePair object into file /// </summary> // <param name="fileName">full path of outupt xml file</param> // <param name="exception">output Exception value if failed</param> // <returns>true if can serialize and save into file; otherwise, false</returns> public virtual bool SaveToFile(string fileName, out System.Exception exception) { exception = null; try { string xmlString = Serialize(); System.IO.FileInfo xmlFile = new System.IO.FileInfo(fileName); System.IO.StreamWriter streamWriter = xmlFile.CreateText(); streamWriter.WriteLine(xmlString); streamWriter.Close(); return true; } catch (System.Exception e) { exception = e; return false; } } /// <summary> /// Deserializes workflow markup from file into an NameValuePair object /// </summary> // <param name="xml">string workflow markup to deserialize</param> // <param name="obj">Output NameValuePair object</param> // <param name="exception">output Exception value if deserialize failed</param> // <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool LoadFromFile(string fileName, out NameValuePair obj, out System.Exception exception) { exception = null; obj = null; try { System.IO.FileStream file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); System.IO.StreamReader sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return Deserialize(xmlString, out obj, out exception); } catch (System.Exception ex) { exception = ex; return false; } } } /// <summary> /// Repro /// </summary> public partial class AttributeLists { [EditorBrowsable(EditorBrowsableState.Never)] private List<NameValuePair> arrayOfNameValuePairField; /// <summary> /// .ctor class constructor /// </summary> public AttributeLists() { if ((this.arrayOfNameValuePairField == null)) { this.arrayOfNameValuePairField = new List<NameValuePair>(); } } [System.Xml.Serialization.XmlArrayItemAttribute("NameValuePair", typeof(NameValuePair), IsNullable = false)] public List<NameValuePair> ArrayOfNameValuePair { get { return this.arrayOfNameValuePairField; } set { this.arrayOfNameValuePairField = value; } } /// <summary> /// Serializes current AttributeLists object into an XML document /// </summary> // <returns>string XML value</returns> public virtual string Serialize() { System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(this.GetType()); System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); xmlSerializer.Serialize(memoryStream, this); memoryStream.Seek(0, System.IO.SeekOrigin.Begin); System.IO.StreamReader streamReader = new System.IO.StreamReader(memoryStream); return streamReader.ReadToEnd(); } /// <summary> /// Deserializes workflow markup into an AttributeLists object /// </summary> // <param name="xml">string workflow markup to deserialize</param> // <param name="obj">Output AttributeLists object</param> // <param name="exception">output Exception value if deserialize failed</param> // <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool Deserialize(string xml, out AttributeLists obj, out System.Exception exception) { exception = null; obj = null; try { System.IO.StringReader stringReader = new System.IO.StringReader(xml); System.Xml.XmlTextReader xmlTextReader = new System.Xml.XmlTextReader(stringReader); System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(AttributeLists)); obj = ((AttributeLists)(xmlSerializer.Deserialize(xmlTextReader))); return true; } catch (System.Exception ex) { exception = ex; return false; } } /// <summary> /// Serializes current AttributeLists object into file /// </summary> // <param name="fileName">full path of outupt xml file</param> // <param name="exception">output Exception value if failed</param> // <returns>true if can serialize and save into file; otherwise, false</returns> public virtual bool SaveToFile(string fileName, out System.Exception exception) { exception = null; try { string xmlString = Serialize(); System.IO.FileInfo xmlFile = new System.IO.FileInfo(fileName); System.IO.StreamWriter streamWriter = xmlFile.CreateText(); streamWriter.WriteLine(xmlString); streamWriter.Close(); return true; } catch (System.Exception e) { exception = e; return false; } } /// <summary> /// Deserializes workflow markup from file into an AttributeLists object /// </summary> // <param name="xml">string workflow markup to deserialize</param> // <param name="obj">Output AttributeLists object</param> // <param name="exception">output Exception value if deserialize failed</param> // <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool LoadFromFile(string fileName, out AttributeLists obj, out System.Exception exception) { exception = null; obj = null; try { System.IO.FileStream file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); System.IO.StreamReader sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return Deserialize(xmlString, out obj, out exception); } catch (System.Exception ex) { exception = ex; return false; } } } /// <summary> /// Repro /// </summary> public partial class ArrayOfNameValuePair { [EditorBrowsable(EditorBrowsableState.Never)] private List<NameValuePair> nameValuePairField; /// <summary> /// .ctor class constructor /// </summary> public ArrayOfNameValuePair() { if ((this.nameValuePairField == null)) { this.nameValuePairField = new List<NameValuePair>(); } } public List<NameValuePair> NameValuePair { get { return this.nameValuePairField; } set { this.nameValuePairField = value; } } /// <summary> /// Serializes current ArrayOfNameValuePair object into an XML document /// </summary> // <returns>string XML value</returns> public virtual string Serialize() { System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(this.GetType()); System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); xmlSerializer.Serialize(memoryStream, this); memoryStream.Seek(0, System.IO.SeekOrigin.Begin); System.IO.StreamReader streamReader = new System.IO.StreamReader(memoryStream); return streamReader.ReadToEnd(); } /// <summary> /// Deserializes workflow markup into an ArrayOfNameValuePair object /// </summary> // <param name="xml">string workflow markup to deserialize</param> // <param name="obj">Output ArrayOfNameValuePair object</param> // <param name="exception">output Exception value if deserialize failed</param> // <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool Deserialize(string xml, out ArrayOfNameValuePair obj, out System.Exception exception) { exception = null; obj = null; try { System.IO.StringReader stringReader = new System.IO.StringReader(xml); System.Xml.XmlTextReader xmlTextReader = new System.Xml.XmlTextReader(stringReader); System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(ArrayOfNameValuePair)); obj = ((ArrayOfNameValuePair)(xmlSerializer.Deserialize(xmlTextReader))); return true; } catch (System.Exception ex) { exception = ex; return false; } } /// <summary> /// Serializes current ArrayOfNameValuePair object into file /// </summary> // <param name="fileName">full path of outupt xml file</param> // <param name="exception">output Exception value if failed</param> // <returns>true if can serialize and save into file; otherwise, false</returns> public virtual bool SaveToFile(string fileName, out System.Exception exception) { exception = null; try { string xmlString = Serialize(); System.IO.FileInfo xmlFile = new System.IO.FileInfo(fileName); System.IO.StreamWriter streamWriter = xmlFile.CreateText(); streamWriter.WriteLine(xmlString); streamWriter.Close(); return true; } catch (System.Exception e) { exception = e; return false; } } /// <summary> /// Deserializes workflow markup from file into an ArrayOfNameValuePair object /// </summary> // <param name="xml">string workflow markup to deserialize</param> // <param name="obj">Output ArrayOfNameValuePair object</param> // <param name="exception">output Exception value if deserialize failed</param> // <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool LoadFromFile(string fileName, out ArrayOfNameValuePair obj, out System.Exception exception) { exception = null; obj = null; try { System.IO.FileStream file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); System.IO.StreamReader sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return Deserialize(xmlString, out obj, out exception); } catch (System.Exception ex) { exception = ex; return false; } } } }