Advertisement
evanjs

Xsd2code MyAnimeList(Manga).cs

Apr 15th, 2014
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 22.31 KB | None | 0 0
  1. // ------------------------------------------------------------------------------
  2. //  <auto-generated>
  3. //    Generated by Xsd2Code. Version 3.4.0.37595
  4. //    <NameSpace>MalApp2</NameSpace><Collection>Array</Collection><codeType>CSharp</codeType><EnableDataBinding>False</EnableDataBinding><EnableLazyLoading>False</EnableLazyLoading><TrackingChangesEnable>False</TrackingChangesEnable><GenTrackingClasses>False</GenTrackingClasses><HidePrivateFieldInIDE>False</HidePrivateFieldInIDE><EnableSummaryComment>False</EnableSummaryComment><VirtualProp>False</VirtualProp><IncludeSerializeMethod>True</IncludeSerializeMethod><UseBaseClass>False</UseBaseClass><GenBaseClass>False</GenBaseClass><GenerateCloneMethod>False</GenerateCloneMethod><GenerateDataContracts>False</GenerateDataContracts><CodeBaseTag>Net40</CodeBaseTag><SerializeMethodName>Serialize</SerializeMethodName><DeserializeMethodName>Deserialize</DeserializeMethodName><SaveToFileMethodName>SaveToFile</SaveToFileMethodName><LoadFromFileMethodName>LoadFromFile</LoadFromFileMethodName><GenerateXMLAttributes>False</GenerateXMLAttributes><EnableEncoding>False</EnableEncoding><AutomaticProperties>False</AutomaticProperties><GenerateShouldSerialize>False</GenerateShouldSerialize><DisableDebug>False</DisableDebug><PropNameSpecified>Default</PropNameSpecified><Encoder>UTF8</Encoder><CustomUsings></CustomUsings><ExcludeIncludedTypes>False</ExcludeIncludedTypes><EnableInitializeFields>True</EnableInitializeFields>
  5. //  </auto-generated>
  6. // ------------------------------------------------------------------------------
  7. namespace MalApp2
  8. {
  9.     using System;
  10.     using System.Diagnostics;
  11.     using System.Xml.Serialization;
  12.     using System.Collections;
  13.     using System.Xml.Schema;
  14.     using System.ComponentModel;
  15.     using System.IO;
  16.     using System.Text;
  17.  
  18.  
  19.     public partial class myanimelist
  20.     {
  21.  
  22.         private myanimelistMyinfo myinfoField;
  23.  
  24.         private myanimelistManga[] mangaField;
  25.  
  26.         private static System.Xml.Serialization.XmlSerializer serializer;
  27.  
  28.         public myanimelistMyinfo myinfo
  29.         {
  30.             get
  31.             {
  32.                 return this.myinfoField;
  33.             }
  34.             set
  35.             {
  36.                 this.myinfoField = value;
  37.             }
  38.         }
  39.  
  40.         public myanimelistManga[] manga
  41.         {
  42.             get
  43.             {
  44.                 return this.mangaField;
  45.             }
  46.             set
  47.             {
  48.                 this.mangaField = value;
  49.             }
  50.         }
  51.  
  52.         private static System.Xml.Serialization.XmlSerializer Serializer
  53.         {
  54.             get
  55.             {
  56.                 if ((serializer == null))
  57.                 {
  58.                     serializer = new System.Xml.Serialization.XmlSerializer(typeof(myanimelist));
  59.                 }
  60.                 return serializer;
  61.             }
  62.         }
  63.  
  64.         #region Serialize/Deserialize
  65.         /// <summary>
  66.         /// Serializes current myanimelist object into an XML document
  67.         /// </summary>
  68.         /// <returns>string XML value</returns>
  69.         public virtual string Serialize()
  70.         {
  71.             System.IO.StreamReader streamReader = null;
  72.             System.IO.MemoryStream memoryStream = null;
  73.             try
  74.             {
  75.                 memoryStream = new System.IO.MemoryStream();
  76.                 Serializer.Serialize(memoryStream, this);
  77.                 memoryStream.Seek(0, System.IO.SeekOrigin.Begin);
  78.                 streamReader = new System.IO.StreamReader(memoryStream);
  79.                 return streamReader.ReadToEnd();
  80.             }
  81.             finally
  82.             {
  83.                 if ((streamReader != null))
  84.                 {
  85.                     streamReader.Dispose();
  86.                 }
  87.                 if ((memoryStream != null))
  88.                 {
  89.                     memoryStream.Dispose();
  90.                 }
  91.             }
  92.         }
  93.  
  94.         /// <summary>
  95.         /// Deserializes workflow markup into an myanimelist object
  96.         /// </summary>
  97.         /// <param name="xml">string workflow markup to deserialize</param>
  98.         /// <param name="obj">Output myanimelist object</param>
  99.         /// <param name="exception">output Exception value if deserialize failed</param>
  100.         /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
  101.         public static bool Deserialize(string xml, out myanimelist obj, out System.Exception exception)
  102.         {
  103.             exception = null;
  104.             obj = default(myanimelist);
  105.             try
  106.             {
  107.                 obj = Deserialize(xml);
  108.                 return true;
  109.             }
  110.             catch (System.Exception ex)
  111.             {
  112.                 exception = ex;
  113.                 return false;
  114.             }
  115.         }
  116.  
  117.         public static bool Deserialize(string xml, out myanimelist obj)
  118.         {
  119.             System.Exception exception = null;
  120.             return Deserialize(xml, out obj, out exception);
  121.         }
  122.  
  123.         public static myanimelist Deserialize(string xml)
  124.         {
  125.             System.IO.StringReader stringReader = null;
  126.             try
  127.             {
  128.                 stringReader = new System.IO.StringReader(xml);
  129.                 return ((myanimelist)(Serializer.Deserialize(System.Xml.XmlReader.Create(stringReader))));
  130.             }
  131.             finally
  132.             {
  133.                 if ((stringReader != null))
  134.                 {
  135.                     stringReader.Dispose();
  136.                 }
  137.             }
  138.         }
  139.  
  140.         /// <summary>
  141.         /// Serializes current myanimelist object into file
  142.         /// </summary>
  143.         /// <param name="fileName">full path of outupt xml file</param>
  144.         /// <param name="exception">output Exception value if failed</param>
  145.         /// <returns>true if can serialize and save into file; otherwise, false</returns>
  146.         public virtual bool SaveToFile(string fileName, out System.Exception exception)
  147.         {
  148.             exception = null;
  149.             try
  150.             {
  151.                 SaveToFile(fileName);
  152.                 return true;
  153.             }
  154.             catch (System.Exception e)
  155.             {
  156.                 exception = e;
  157.                 return false;
  158.             }
  159.         }
  160.  
  161.         public virtual void SaveToFile(string fileName)
  162.         {
  163.             System.IO.StreamWriter streamWriter = null;
  164.             try
  165.             {
  166.                 string xmlString = Serialize();
  167.                 System.IO.FileInfo xmlFile = new System.IO.FileInfo(fileName);
  168.                 streamWriter = xmlFile.CreateText();
  169.                 streamWriter.WriteLine(xmlString);
  170.                 streamWriter.Close();
  171.             }
  172.             finally
  173.             {
  174.                 if ((streamWriter != null))
  175.                 {
  176.                     streamWriter.Dispose();
  177.                 }
  178.             }
  179.         }
  180.  
  181.         /// <summary>
  182.         /// Deserializes xml markup from file into an myanimelist object
  183.         /// </summary>
  184.         /// <param name="fileName">string xml file to load and deserialize</param>
  185.         /// <param name="obj">Output myanimelist object</param>
  186.         /// <param name="exception">output Exception value if deserialize failed</param>
  187.         /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
  188.         public static bool LoadFromFile(string fileName, out myanimelist obj, out System.Exception exception)
  189.         {
  190.             exception = null;
  191.             obj = default(myanimelist);
  192.             try
  193.             {
  194.                 obj = LoadFromFile(fileName);
  195.                 return true;
  196.             }
  197.             catch (System.Exception ex)
  198.             {
  199.                 exception = ex;
  200.                 return false;
  201.             }
  202.         }
  203.  
  204.         public static bool LoadFromFile(string fileName, out myanimelist obj)
  205.         {
  206.             System.Exception exception = null;
  207.             return LoadFromFile(fileName, out obj, out exception);
  208.         }
  209.  
  210.         public static myanimelist LoadFromFile(string fileName)
  211.         {
  212.             System.IO.FileStream file = null;
  213.             System.IO.StreamReader sr = null;
  214.             try
  215.             {
  216.                 file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read);
  217.                 sr = new System.IO.StreamReader(file);
  218.                 string xmlString = sr.ReadToEnd();
  219.                 sr.Close();
  220.                 file.Close();
  221.                 return Deserialize(xmlString);
  222.             }
  223.             finally
  224.             {
  225.                 if ((file != null))
  226.                 {
  227.                     file.Dispose();
  228.                 }
  229.                 if ((sr != null))
  230.                 {
  231.                     sr.Dispose();
  232.                 }
  233.             }
  234.         }
  235.         #endregion
  236.     }
  237.  
  238.     public partial class myanimelistMyinfo
  239.     {
  240.  
  241.         private int user_idField;
  242.  
  243.         private string user_nameField;
  244.  
  245.         private sbyte user_readingField;
  246.  
  247.         private sbyte user_completedField;
  248.  
  249.         private sbyte user_onholdField;
  250.  
  251.         private sbyte user_droppedField;
  252.  
  253.         private sbyte user_plantoreadField;
  254.  
  255.         private float user_days_spent_watchingField;
  256.  
  257.         private static System.Xml.Serialization.XmlSerializer serializer;
  258.  
  259.         public int user_id
  260.         {
  261.             get
  262.             {
  263.                 return this.user_idField;
  264.             }
  265.             set
  266.             {
  267.                 this.user_idField = value;
  268.             }
  269.         }
  270.  
  271.         public string user_name
  272.         {
  273.             get
  274.             {
  275.                 return this.user_nameField;
  276.             }
  277.             set
  278.             {
  279.                 this.user_nameField = value;
  280.             }
  281.         }
  282.  
  283.         public sbyte user_reading
  284.         {
  285.             get
  286.             {
  287.                 return this.user_readingField;
  288.             }
  289.             set
  290.             {
  291.                 this.user_readingField = value;
  292.             }
  293.         }
  294.  
  295.         public sbyte user_completed
  296.         {
  297.             get
  298.             {
  299.                 return this.user_completedField;
  300.             }
  301.             set
  302.             {
  303.                 this.user_completedField = value;
  304.             }
  305.         }
  306.  
  307.         public sbyte user_onhold
  308.         {
  309.             get
  310.             {
  311.                 return this.user_onholdField;
  312.             }
  313.             set
  314.             {
  315.                 this.user_onholdField = value;
  316.             }
  317.         }
  318.  
  319.         public sbyte user_dropped
  320.         {
  321.             get
  322.             {
  323.                 return this.user_droppedField;
  324.             }
  325.             set
  326.             {
  327.                 this.user_droppedField = value;
  328.             }
  329.         }
  330.  
  331.         public sbyte user_plantoread
  332.         {
  333.             get
  334.             {
  335.                 return this.user_plantoreadField;
  336.             }
  337.             set
  338.             {
  339.                 this.user_plantoreadField = value;
  340.             }
  341.         }
  342.  
  343.         public float user_days_spent_watching
  344.         {
  345.             get
  346.             {
  347.                 return this.user_days_spent_watchingField;
  348.             }
  349.             set
  350.             {
  351.                 this.user_days_spent_watchingField = value;
  352.             }
  353.         }
  354.  
  355.         private static System.Xml.Serialization.XmlSerializer Serializer
  356.         {
  357.             get
  358.             {
  359.                 if ((serializer == null))
  360.                 {
  361.                     serializer = new System.Xml.Serialization.XmlSerializer(typeof(myanimelistMyinfo));
  362.                 }
  363.                 return serializer;
  364.             }
  365.         }
  366.  
  367.         #region Serialize/Deserialize
  368.         /// <summary>
  369.         /// Serializes current myanimelistMyinfo object into an XML document
  370.         /// </summary>
  371.         /// <returns>string XML value</returns>
  372.         public virtual string Serialize()
  373.         {
  374.             System.IO.StreamReader streamReader = null;
  375.             System.IO.MemoryStream memoryStream = null;
  376.             try
  377.             {
  378.                 memoryStream = new System.IO.MemoryStream();
  379.                 Serializer.Serialize(memoryStream, this);
  380.                 memoryStream.Seek(0, System.IO.SeekOrigin.Begin);
  381.                 streamReader = new System.IO.StreamReader(memoryStream);
  382.                 return streamReader.ReadToEnd();
  383.             }
  384.             finally
  385.             {
  386.                 if ((streamReader != null))
  387.                 {
  388.                     streamReader.Dispose();
  389.                 }
  390.                 if ((memoryStream != null))
  391.                 {
  392.                     memoryStream.Dispose();
  393.                 }
  394.             }
  395.         }
  396.  
  397.         /// <summary>
  398.         /// Deserializes workflow markup into an myanimelistMyinfo object
  399.         /// </summary>
  400.         /// <param name="xml">string workflow markup to deserialize</param>
  401.         /// <param name="obj">Output myanimelistMyinfo object</param>
  402.         /// <param name="exception">output Exception value if deserialize failed</param>
  403.         /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
  404.         public static bool Deserialize(string xml, out myanimelistMyinfo obj, out System.Exception exception)
  405.         {
  406.             exception = null;
  407.             obj = default(myanimelistMyinfo);
  408.             try
  409.             {
  410.                 obj = Deserialize(xml);
  411.                 return true;
  412.             }
  413.             catch (System.Exception ex)
  414.             {
  415.                 exception = ex;
  416.                 return false;
  417.             }
  418.         }
  419.  
  420.         public static bool Deserialize(string xml, out myanimelistMyinfo obj)
  421.         {
  422.             System.Exception exception = null;
  423.             return Deserialize(xml, out obj, out exception);
  424.         }
  425.  
  426.         public static myanimelistMyinfo Deserialize(string xml)
  427.         {
  428.             System.IO.StringReader stringReader = null;
  429.             try
  430.             {
  431.                 stringReader = new System.IO.StringReader(xml);
  432.                 return ((myanimelistMyinfo)(Serializer.Deserialize(System.Xml.XmlReader.Create(stringReader))));
  433.             }
  434.             finally
  435.             {
  436.                 if ((stringReader != null))
  437.                 {
  438.                     stringReader.Dispose();
  439.                 }
  440.             }
  441.         }
  442.  
  443.         /// <summary>
  444.         /// Serializes current myanimelistMyinfo object into file
  445.         /// </summary>
  446.         /// <param name="fileName">full path of outupt xml file</param>
  447.         /// <param name="exception">output Exception value if failed</param>
  448.         /// <returns>true if can serialize and save into file; otherwise, false</returns>
  449.         public virtual bool SaveToFile(string fileName, out System.Exception exception)
  450.         {
  451.             exception = null;
  452.             try
  453.             {
  454.                 SaveToFile(fileName);
  455.                 return true;
  456.             }
  457.             catch (System.Exception e)
  458.             {
  459.                 exception = e;
  460.                 return false;
  461.             }
  462.         }
  463.  
  464.         public virtual void SaveToFile(string fileName)
  465.         {
  466.             System.IO.StreamWriter streamWriter = null;
  467.             try
  468.             {
  469.                 string xmlString = Serialize();
  470.                 System.IO.FileInfo xmlFile = new System.IO.FileInfo(fileName);
  471.                 streamWriter = xmlFile.CreateText();
  472.                 streamWriter.WriteLine(xmlString);
  473.                 streamWriter.Close();
  474.             }
  475.             finally
  476.             {
  477.                 if ((streamWriter != null))
  478.                 {
  479.                     streamWriter.Dispose();
  480.                 }
  481.             }
  482.         }
  483.  
  484.         /// <summary>
  485.         /// Deserializes xml markup from file into an myanimelistMyinfo object
  486.         /// </summary>
  487.         /// <param name="fileName">string xml file to load and deserialize</param>
  488.         /// <param name="obj">Output myanimelistMyinfo object</param>
  489.         /// <param name="exception">output Exception value if deserialize failed</param>
  490.         /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
  491.         public static bool LoadFromFile(string fileName, out myanimelistMyinfo obj, out System.Exception exception)
  492.         {
  493.             exception = null;
  494.             obj = default(myanimelistMyinfo);
  495.             try
  496.             {
  497.                 obj = LoadFromFile(fileName);
  498.                 return true;
  499.             }
  500.             catch (System.Exception ex)
  501.             {
  502.                 exception = ex;
  503.                 return false;
  504.             }
  505.         }
  506.  
  507.         public static bool LoadFromFile(string fileName, out myanimelistMyinfo obj)
  508.         {
  509.             System.Exception exception = null;
  510.             return LoadFromFile(fileName, out obj, out exception);
  511.         }
  512.  
  513.         public static myanimelistMyinfo LoadFromFile(string fileName)
  514.         {
  515.             System.IO.FileStream file = null;
  516.             System.IO.StreamReader sr = null;
  517.             try
  518.             {
  519.                 file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read);
  520.                 sr = new System.IO.StreamReader(file);
  521.                 string xmlString = sr.ReadToEnd();
  522.                 sr.Close();
  523.                 file.Close();
  524.                 return Deserialize(xmlString);
  525.             }
  526.             finally
  527.             {
  528.                 if ((file != null))
  529.                 {
  530.                     file.Dispose();
  531.                 }
  532.                 if ((sr != null))
  533.                 {
  534.                     sr.Dispose();
  535.                 }
  536.             }
  537.         }
  538.         #endregion
  539.     }
  540.  
  541.     public partial class myanimelistManga
  542.     {
  543.  
  544.         private short series_mangadb_idField;
  545.  
  546.         private string series_titleField;
  547.  
  548.         private string series_synonymsField;
  549.  
  550.         private sbyte series_typeField;
  551.  
  552.         private short series_chaptersField;
  553.  
  554.         private sbyte series_volumesField;
  555.  
  556.         private sbyte series_statusField;
  557.  
  558.         private string series_startField;
  559.  
  560.         private string series_endField;
  561.  
  562.         private string series_imageField;
  563.  
  564.         private int my_idField;
  565.  
  566.         private short my_read_chaptersField;
  567.  
  568.         private sbyte my_read_volumesField;
  569.  
  570.         private string my_start_dateField;
  571.  
  572.         private string my_finish_dateField;
  573.  
  574.         private sbyte my_scoreField;
  575.  
  576.         private sbyte my_statusField;
  577.  
  578.         private string my_rereadinggField;
  579.  
  580.         private sbyte my_rereading_chapField;
  581.  
  582.         private int my_last_updatedField;
  583.  
  584.         private string my_tagsField;
  585.  
  586.         private static System.Xml.Serialization.XmlSerializer serializer;
  587.  
  588.         public short series_mangadb_id
  589.         {
  590.             get
  591.             {
  592.                 return this.series_mangadb_idField;
  593.             }
  594.             set
  595.             {
  596.                 this.series_mangadb_idField = value;
  597.             }
  598.         }
  599.  
  600.         public string series_title
  601.         {
  602.             get
  603.             {
  604.                 return this.series_titleField;
  605.             }
  606.             set
  607.             {
  608.                 this.series_titleField = value;
  609.             }
  610.         }
  611.  
  612.         public string series_synonyms
  613.         {
  614.             get
  615.             {
  616.                 return this.series_synonymsField;
  617.             }
  618.             set
  619.             {
  620.                 this.series_synonymsField = value;
  621.             }
  622.         }
  623.  
  624.         public sbyte series_type
  625.         {
  626.             get
  627.             {
  628.                 return this.series_typeField;
  629.             }
  630.             set
  631.             {
  632.                 this.series_typeField = value;
  633.             }
  634.         }
  635.  
  636.         public short series_chapters
  637.         {
  638.             get
  639.             {
  640.                 return this.series_chaptersField;
  641.             }
  642.             set
  643.             {
  644.                 this.series_chaptersField = value;
  645.             }
  646.         }
  647.  
  648.         public sbyte series_volumes
  649.         {
  650.             get
  651.             {
  652.                 return this.series_volumesField;
  653.             }
  654.             set
  655.             {
  656.                 this.series_volumesField = value;
  657.             }
  658.         }
  659.  
  660.         public sbyte series_status
  661.         {
  662.             get
  663.             {
  664.                 return this.series_statusField;
  665.             }
  666.             set
  667.             {
  668.                 this.series_statusField = value;
  669.             }
  670.         }
  671.  
  672.         public string series_start
  673.         {
  674.             get
  675.             {
  676.                 return this.series_startField;
  677.             }
  678.             set
  679.             {
  680.                 this.series_startField = value;
  681.             }
  682.         }
  683.  
  684.         public string series_end
  685.         {
  686.             get
  687.             {
  688.                 return this.series_endField;
  689.             }
  690.             set
  691.             {
  692.                 this.series_endField = value;
  693.             }
  694.         }
  695.  
  696.         public string series_image
  697.         {
  698.             get
  699.             {
  700.                 return this.series_imageField;
  701.             }
  702.             set
  703.             {
  704.                 this.series_imageField = value;
  705.             }
  706.         }
  707.  
  708.         public int my_id
  709.         {
  710.             get
  711.             {
  712.                 return this.my_idField;
  713.             }
  714.             set
  715.             {
  716.                 this.my_idField = value;
  717.             }
  718.         }
  719.  
  720.         public short my_read_chapters
  721.         {
  722.             get
  723.             {
  724.                 return this.my_read_chaptersField;
  725.             }
  726.             set
  727.             {
  728.                 this.my_read_chaptersField = value;
  729.             }
  730.         }
  731.  
  732.         public sbyte my_read_volumes
  733.         {
  734.             get
  735.             {
  736.                 return this.my_read_volumesField;
  737.             }
  738.             set
  739.             {
  740.                 this.my_read_volumesField = value;
  741.             }
  742.         }
  743.  
  744.         public string my_start_date
  745.         {
  746.             get
  747.             {
  748.                 return this.my_start_dateField;
  749.             }
  750.             set
  751.             {
  752.                 this.my_start_dateField = value;
  753.             }
  754.         }
  755.  
  756.         public string my_finish_date
  757.         {
  758.             get
  759.             {
  760.                 return this.my_finish_dateField;
  761.             }
  762.             set
  763.             {
  764.                 this.my_finish_dateField = value;
  765.             }
  766.         }
  767.  
  768.         public sbyte my_score
  769.         {
  770.             get
  771.             {
  772.                 return this.my_scoreField;
  773.             }
  774.             set
  775.             {
  776.                 this.my_scoreField = value;
  777.             }
  778.         }
  779.  
  780.         public sbyte my_status
  781.         {
  782.             get
  783.             {
  784.                 return this.my_statusField;
  785.             }
  786.             set
  787.             {
  788.                 this.my_statusField = value;
  789.             }
  790.         }
  791.  
  792.         public string my_rereadingg
  793.         {
  794.             get
  795.             {
  796.                 return this.my_rereadinggField;
  797.             }
  798.             set
  799.             {
  800.                 this.my_rereadinggField = value;
  801.             }
  802.         }
  803.  
  804.         public sbyte my_rereading_chap
  805.         {
  806.             get
  807.             {
  808.                 return this.my_rereading_chapField;
  809.             }
  810.             set
  811.             {
  812.                 this.my_rereading_chapField = value;
  813.             }
  814.         }
  815.  
  816.         public int my_last_updated
  817.         {
  818.             get
  819.             {
  820.                 return this.my_last_updatedField;
  821.             }
  822.             set
  823.             {
  824.                 this.my_last_updatedField = value;
  825.             }
  826.         }
  827.  
  828.         public string my_tags
  829.         {
  830.             get
  831.             {
  832.                 return this.my_tagsField;
  833.             }
  834.             set
  835.             {
  836.                 this.my_tagsField = value;
  837.             }
  838.         }
  839.  
  840.         private static System.Xml.Serialization.XmlSerializer Serializer
  841.         {
  842.             get
  843.             {
  844.                 if ((serializer == null))
  845.                 {
  846.                     serializer = new System.Xml.Serialization.XmlSerializer(typeof(myanimelistManga));
  847.                 }
  848.                 return serializer;
  849.             }
  850.         }
  851.  
  852.         #region Serialize/Deserialize
  853.         /// <summary>
  854.         /// Serializes current myanimelistManga object into an XML document
  855.         /// </summary>
  856.         /// <returns>string XML value</returns>
  857.         public virtual string Serialize()
  858.         {
  859.             System.IO.StreamReader streamReader = null;
  860.             System.IO.MemoryStream memoryStream = null;
  861.             try
  862.             {
  863.                 memoryStream = new System.IO.MemoryStream();
  864.                 Serializer.Serialize(memoryStream, this);
  865.                 memoryStream.Seek(0, System.IO.SeekOrigin.Begin);
  866.                 streamReader = new System.IO.StreamReader(memoryStream);
  867.                 return streamReader.ReadToEnd();
  868.             }
  869.             finally
  870.             {
  871.                 if ((streamReader != null))
  872.                 {
  873.                     streamReader.Dispose();
  874.                 }
  875.                 if ((memoryStream != null))
  876.                 {
  877.                     memoryStream.Dispose();
  878.                 }
  879.             }
  880.         }
  881.  
  882.         /// <summary>
  883.         /// Deserializes workflow markup into an myanimelistManga object
  884.         /// </summary>
  885.         /// <param name="xml">string workflow markup to deserialize</param>
  886.         /// <param name="obj">Output myanimelistManga object</param>
  887.         /// <param name="exception">output Exception value if deserialize failed</param>
  888.         /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
  889.         public static bool Deserialize(string xml, out myanimelistManga obj, out System.Exception exception)
  890.         {
  891.             exception = null;
  892.             obj = default(myanimelistManga);
  893.             try
  894.             {
  895.                 obj = Deserialize(xml);
  896.                 return true;
  897.             }
  898.             catch (System.Exception ex)
  899.             {
  900.                 exception = ex;
  901.                 return false;
  902.             }
  903.         }
  904.  
  905.         public static bool Deserialize(string xml, out myanimelistManga obj)
  906.         {
  907.             System.Exception exception = null;
  908.             return Deserialize(xml, out obj, out exception);
  909.         }
  910.  
  911.         public static myanimelistManga Deserialize(string xml)
  912.         {
  913.             System.IO.StringReader stringReader = null;
  914.             try
  915.             {
  916.                 stringReader = new System.IO.StringReader(xml);
  917.                 return ((myanimelistManga)(Serializer.Deserialize(System.Xml.XmlReader.Create(stringReader))));
  918.             }
  919.             finally
  920.             {
  921.                 if ((stringReader != null))
  922.                 {
  923.                     stringReader.Dispose();
  924.                 }
  925.             }
  926.         }
  927.  
  928.         /// <summary>
  929.         /// Serializes current myanimelistManga object into file
  930.         /// </summary>
  931.         /// <param name="fileName">full path of outupt xml file</param>
  932.         /// <param name="exception">output Exception value if failed</param>
  933.         /// <returns>true if can serialize and save into file; otherwise, false</returns>
  934.         public virtual bool SaveToFile(string fileName, out System.Exception exception)
  935.         {
  936.             exception = null;
  937.             try
  938.             {
  939.                 SaveToFile(fileName);
  940.                 return true;
  941.             }
  942.             catch (System.Exception e)
  943.             {
  944.                 exception = e;
  945.                 return false;
  946.             }
  947.         }
  948.  
  949.         public virtual void SaveToFile(string fileName)
  950.         {
  951.             System.IO.StreamWriter streamWriter = null;
  952.             try
  953.             {
  954.                 string xmlString = Serialize();
  955.                 System.IO.FileInfo xmlFile = new System.IO.FileInfo(fileName);
  956.                 streamWriter = xmlFile.CreateText();
  957.                 streamWriter.WriteLine(xmlString);
  958.                 streamWriter.Close();
  959.             }
  960.             finally
  961.             {
  962.                 if ((streamWriter != null))
  963.                 {
  964.                     streamWriter.Dispose();
  965.                 }
  966.             }
  967.         }
  968.  
  969.         /// <summary>
  970.         /// Deserializes xml markup from file into an myanimelistManga object
  971.         /// </summary>
  972.         /// <param name="fileName">string xml file to load and deserialize</param>
  973.         /// <param name="obj">Output myanimelistManga object</param>
  974.         /// <param name="exception">output Exception value if deserialize failed</param>
  975.         /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
  976.         public static bool LoadFromFile(string fileName, out myanimelistManga obj, out System.Exception exception)
  977.         {
  978.             exception = null;
  979.             obj = default(myanimelistManga);
  980.             try
  981.             {
  982.                 obj = LoadFromFile(fileName);
  983.                 return true;
  984.             }
  985.             catch (System.Exception ex)
  986.             {
  987.                 exception = ex;
  988.                 return false;
  989.             }
  990.         }
  991.  
  992.         public static bool LoadFromFile(string fileName, out myanimelistManga obj)
  993.         {
  994.             System.Exception exception = null;
  995.             return LoadFromFile(fileName, out obj, out exception);
  996.         }
  997.  
  998.         public static myanimelistManga LoadFromFile(string fileName)
  999.         {
  1000.             System.IO.FileStream file = null;
  1001.             System.IO.StreamReader sr = null;
  1002.             try
  1003.             {
  1004.                 file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read);
  1005.                 sr = new System.IO.StreamReader(file);
  1006.                 string xmlString = sr.ReadToEnd();
  1007.                 sr.Close();
  1008.                 file.Close();
  1009.                 return Deserialize(xmlString);
  1010.             }
  1011.             finally
  1012.             {
  1013.                 if ((file != null))
  1014.                 {
  1015.                     file.Dispose();
  1016.                 }
  1017.                 if ((sr != null))
  1018.                 {
  1019.                     sr.Dispose();
  1020.                 }
  1021.             }
  1022.         }
  1023.         #endregion
  1024.     }
  1025. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement