// ------------------------------------------------------------------------------ // // Generated by Xsd2Code. Version 2.8.2.29599 // Xsd2Code.TestUnitListCSharpFalseTrueTrueTrueFalseFalseNet20SerializeDeserializeSaveToFileLoadFromFileFalseFalseFalse // // ------------------------------------------------------------------------------ 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; /// /// The root element that wraps up all UIElements into an array that's consumed by KAF. /// public partial class ArrayOfMyElement { [EditorBrowsable(EditorBrowsableState.Never)] private List myElementField; /// /// .ctor class constructor /// public ArrayOfMyElement() { if ((this.myElementField == null)) { this.myElementField = new List(); } } public List MyElement { get { return this.myElementField; } set { this.myElementField = value; } } /// /// Serializes current ArrayOfMyElement object into an XML document /// // string XML value 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(); } /// /// Deserializes workflow markup into an ArrayOfMyElement object /// // string workflow markup to deserialize // Output ArrayOfMyElement object // output Exception value if deserialize failed // true if this XmlSerializer can deserialize the object; otherwise, false 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; } } /// /// Serializes current ArrayOfMyElement object into file /// // full path of outupt xml file // output Exception value if failed // true if can serialize and save into file; otherwise, false 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; } } /// /// Deserializes workflow markup from file into an ArrayOfMyElement object /// // string workflow markup to deserialize // Output ArrayOfMyElement object // output Exception value if deserialize failed // true if this XmlSerializer can deserialize the object; otherwise, false 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; } } } /// /// Represents a generic object in the user interface such as a button or text box. /// public partial class MyElement { [EditorBrowsable(EditorBrowsableState.Never)] private string nameField; [EditorBrowsable(EditorBrowsableState.Never)] private List attributeListsField; /// /// .ctor class constructor /// public MyElement() { if ((this.attributeListsField == null)) { this.attributeListsField = new List(); } } 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 AttributeLists { get { return this.attributeListsField; } set { this.attributeListsField = value; } } /// /// Serializes current MyElement object into an XML document /// // string XML value 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(); } /// /// Deserializes workflow markup into an MyElement object /// // string workflow markup to deserialize // Output MyElement object // output Exception value if deserialize failed // true if this XmlSerializer can deserialize the object; otherwise, false 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; } } /// /// Serializes current MyElement object into file /// // full path of outupt xml file // output Exception value if failed // true if can serialize and save into file; otherwise, false 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; } } /// /// Deserializes workflow markup from file into an MyElement object /// // string workflow markup to deserialize // Output MyElement object // output Exception value if deserialize failed // true if this XmlSerializer can deserialize the object; otherwise, false 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; } } } /// /// Repro /// 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; } } /// /// Serializes current NameValuePair object into an XML document /// // string XML value 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(); } /// /// Deserializes workflow markup into an NameValuePair object /// // string workflow markup to deserialize // Output NameValuePair object // output Exception value if deserialize failed // true if this XmlSerializer can deserialize the object; otherwise, false 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; } } /// /// Serializes current NameValuePair object into file /// // full path of outupt xml file // output Exception value if failed // true if can serialize and save into file; otherwise, false 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; } } /// /// Deserializes workflow markup from file into an NameValuePair object /// // string workflow markup to deserialize // Output NameValuePair object // output Exception value if deserialize failed // true if this XmlSerializer can deserialize the object; otherwise, false 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; } } } /// /// Repro /// public partial class AttributeLists { [EditorBrowsable(EditorBrowsableState.Never)] private List arrayOfNameValuePairField; /// /// .ctor class constructor /// public AttributeLists() { if ((this.arrayOfNameValuePairField == null)) { this.arrayOfNameValuePairField = new List(); } } [System.Xml.Serialization.XmlArrayItemAttribute("NameValuePair", typeof(NameValuePair), IsNullable = false)] public List ArrayOfNameValuePair { get { return this.arrayOfNameValuePairField; } set { this.arrayOfNameValuePairField = value; } } /// /// Serializes current AttributeLists object into an XML document /// // string XML value 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(); } /// /// Deserializes workflow markup into an AttributeLists object /// // string workflow markup to deserialize // Output AttributeLists object // output Exception value if deserialize failed // true if this XmlSerializer can deserialize the object; otherwise, false 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; } } /// /// Serializes current AttributeLists object into file /// // full path of outupt xml file // output Exception value if failed // true if can serialize and save into file; otherwise, false 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; } } /// /// Deserializes workflow markup from file into an AttributeLists object /// // string workflow markup to deserialize // Output AttributeLists object // output Exception value if deserialize failed // true if this XmlSerializer can deserialize the object; otherwise, false 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; } } } /// /// Repro /// public partial class ArrayOfNameValuePair { [EditorBrowsable(EditorBrowsableState.Never)] private List nameValuePairField; /// /// .ctor class constructor /// public ArrayOfNameValuePair() { if ((this.nameValuePairField == null)) { this.nameValuePairField = new List(); } } public List NameValuePair { get { return this.nameValuePairField; } set { this.nameValuePairField = value; } } /// /// Serializes current ArrayOfNameValuePair object into an XML document /// // string XML value 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(); } /// /// Deserializes workflow markup into an ArrayOfNameValuePair object /// // string workflow markup to deserialize // Output ArrayOfNameValuePair object // output Exception value if deserialize failed // true if this XmlSerializer can deserialize the object; otherwise, false 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; } } /// /// Serializes current ArrayOfNameValuePair object into file /// // full path of outupt xml file // output Exception value if failed // true if can serialize and save into file; otherwise, false 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; } } /// /// Deserializes workflow markup from file into an ArrayOfNameValuePair object /// // string workflow markup to deserialize // Output ArrayOfNameValuePair object // output Exception value if deserialize failed // true if this XmlSerializer can deserialize the object; otherwise, false 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; } } } }