Пример #1
0
    public static void Export(string filename, Topic head) {
      if(filename == null || head == null) {
        throw new ArgumentNullException();
      }
      XDocument doc = new XDocument(new XElement("xst", new XAttribute("path", head.path)));
      if(head.saved) {
        if(head.vType != null) {
          doc.Root.Add(new XAttribute("v", head.ToJson()));
        }
        doc.Root.Add(new XAttribute("s", bool.TrueString));
      }
      foreach(Topic t in head.children) {
        Export(doc.Root, t);
      }

      using(StreamWriter sw = File.CreateText(filename)) {
        using(var writer = new System.Xml.XmlTextWriter(sw)) {
          writer.Formatting = System.Xml.Formatting.Indented;
          writer.QuoteChar = '\'';
          writer.WriteNode(doc.CreateReader(), false);
          writer.Flush();
        }
      }
    }