示例#1
0
 public Models.WordList ParseXml(Stream inputStream)
 {
     WordList.WordListXml wordsXml;
     try
     {
         wordsXml = (WordList.WordListXml)serializer.Deserialize(inputStream);
     }
     catch (InvalidOperationException e)
     {
         throw new ParserException("Unknown file format.", e);
     }
     return(WordListXmlConverter.ConvertToObject(wordsXml));
 }
示例#2
0
        public void GenerateXml(Models.WordList wordList, Stream outputStream)
        {
            WordList.WordListXml wordsXml = WordListXmlConverter.ConvertToXml(wordList);

            XmlWriterSettings xmlWriterSettings = new XmlWriterSettings();

            xmlWriterSettings.Encoding = new UTF8Encoding(false);
            xmlWriterSettings.Indent   = true;
            using (XmlWriter writer = XmlWriter.Create(outputStream, xmlWriterSettings))
            {
                serializer.Serialize(writer, wordsXml);
                writer.Flush();
            }
        }