// ------------------------------------------------------------------------------ // // Generated by Xsd2Code. Version 2.1.3294.28547 // Xsd2Code.TestUnitListCSharpFalseFalseTrueTrueSerializeDeserializeSaveToFileLoadFromFileFalse // // ------------------------------------------------------------------------------ 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; /// [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.3053")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://tempuri.org/Gender.xsd")] [System.Xml.Serialization.XmlRootAttribute(Namespace = "http://tempuri.org/Gender.xsd", IsNullable = false)] public partial class Root { private ksgender genderElementField; private ksgender genderAttributeField; private bool genderAttributeFieldSpecified; private string genderIntAttributeField; /// public ksgender GenderElement { get { return this.genderElementField; } set { this.genderElementField = value; } } /// [System.Xml.Serialization.XmlAttributeAttribute()] public ksgender GenderAttribute { get { return this.genderAttributeField; } set { this.genderAttributeField = value; } } /// [System.Xml.Serialization.XmlIgnoreAttribute()] public bool GenderAttributeSpecified { get { return this.genderAttributeFieldSpecified; } set { this.genderAttributeFieldSpecified = value; } } /// [System.Xml.Serialization.XmlAttributeAttribute(DataType = "integer")] public string GenderIntAttribute { get { return this.genderIntAttributeField; } set { this.genderIntAttributeField = value; } } /// /// Serializes current Root 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 Root object /// // string workflow markup to deserialize // Output Root object // output Exception value if deserialize failed // true if this XmlSerializer can deserialize the object; otherwise, false public static bool Deserialize(string xml, out Root 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(Root)); obj = ((Root)(xmlSerializer.Deserialize(xmlTextReader))); return true; } catch (System.Exception e) { exception = e; return false; } } /// /// Serializes current Root 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 Root object /// // string workflow markup to deserialize // Output Root object // output Exception value if deserialize failed // true if this XmlSerializer can deserialize the object; otherwise, false public static bool LoadFromFile(string fileName, out Root 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 e) { exception = e; return false; } } } /// [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.3053")] [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://tempuri.org/Gender.xsd")] public enum ksgender { /// male, /// female, } }