public static void InitializeCommandTree(Document document)
 {
     // Initialize commands
     document.Initialize();
     var elements = Flatten(document.Children);
     Parallel.ForEach(elements, e => e.Initialize());
 }
 public override void Save(string path, Document document)
 {
     using (var stream = File.Open(path, FileMode.Create, FileAccess.ReadWrite))
     {
         var writer = new BinaryWriter(stream);
         WriteDocument(writer, document);
         stream.Flush();
     }
 }
        public override Document Load(string path)
        {
            using (var stream = File.OpenRead(path))
            {
                var reader = new BinaryReader(stream);
                var document = new Document();
                ReadDocument(reader, document);

                InitializeCommandTree(document);

                return document;
            }
        }
Example #4
0
 public override void Save(string filename, Document document)
 {
     var json = Core.JsonSerializer.Serialize(this);
     File.WriteAllText(filename, json);
 }
Example #5
0
 public abstract void Save(string filename, Document document);
 private static void WriteDocument(BinaryWriter writer, Document document)
 {
     writer.Write(document.Name);
     writer.Write(document.Filename);
     writer.Write(document.Children.Count);
     WriteChildren(writer, document.Children);
 }
 private static void ReadDocument(BinaryReader reader, Document document)
 {
     document.Name = reader.ReadString();
     document.Filename = reader.ReadString();
     ReadChildren(reader, document);
 }