[monodoc] Legacy Tree inheriting Node
authorJeremie Laval <jeremie.laval@gmail.com>
Tue, 12 Feb 2013 11:24:31 +0000 (11:24 +0000)
committerJeremie Laval <jeremie.laval@gmail.com>
Tue, 12 Feb 2013 11:49:34 +0000 (11:49 +0000)
mcs/class/monodoc/Monodoc/Node.cs
mcs/class/monodoc/Monodoc/Tree.cs
mcs/class/monodoc/Monodoc/Tree_Legacy.cs [deleted file]
mcs/class/monodoc/monodoc.dll.sources

index d44db60fccef45e00647682cb096acd9f8127387..4ac430f2dc5321f53137ce046dcaeaa35e61034c 100644 (file)
@@ -28,6 +28,17 @@ namespace Monodoc
                 */
                int address;
 
+#if LEGACY_MODE
+               [Obsolete ("Tree inheriting Node is being phased out. Use the `Tree.RootNode' property instead")]
+               public Node (string caption, string element)
+               {
+                       this.parentTree = (Tree) this;
+                       this.caption = caption;
+                       this.element = element;
+                       parent = null;
+               }
+#endif
+
                public Node (Node parent, string caption, string element) : this (parent.Tree, caption, element)
                {
                        this.parent = parent;
@@ -138,6 +149,11 @@ namespace Monodoc
                        get {
                                return address;
                        }
+#if LEGACY_MODE
+                       set {
+                               address = value;
+                       }
+#endif
                }
        
                /// <summary>
index b3f0bb17110b55b005e8df1ce6f3833523b8708f..42fab437202d8aa0cc06e18e9aff8dcce2698678 100644 (file)
@@ -16,11 +16,10 @@ namespace Monodoc
        /* Ideally this class should also be abstracted to let user have something
         * else than a file as a backing store, a database for instance
         */
-       public
+       public class Tree
 #if LEGACY_MODE
-       partial
+               : Node
 #endif
-       class Tree
        {
                public const long CurrentVersionNumber = 1;
                const int VersionNumberKey = -(int)'v';
@@ -29,13 +28,18 @@ namespace Monodoc
                FileStream InputStream;
                BinaryReader InputReader;
 
+#if !LEGACY_MODE
                // This is the node which contains all the other node of the tree
                Node rootNode;
+#endif
 
                /// <summary>
                ///   Load from file constructor
                /// </summary>
                public Tree (HelpSource hs, string filename)
+#if LEGACY_MODE
+                       : base (null, null)
+#endif
                {
                        HelpSource = hs;
                        Encoding utf8 = new UTF8Encoding (false, true);
@@ -67,21 +71,35 @@ namespace Monodoc
                        }
 
                        var position = InputReader.ReadInt32 ();
+#if !LEGACY_MODE
                        rootNode = new Node (this, position);
-                       InflateNode (rootNode);
+#else
+                       Address = position;
+#endif
+                       InflateNode (RootNode);
                }
 
                /// <summary>
                ///    Tree creation and merged tree constructor
                /// </summary>
-               public Tree (HelpSource hs, string caption, string url) : this (hs, null, caption, url)
+               public Tree (HelpSource hs, string caption, string url)
+#if !LEGACY_MODE
+                       : this (hs, null, caption, url)
+#else
+                       : base (caption, url)
+#endif
                {
                }
 
                public Tree (HelpSource hs, Node parent, string caption, string element)
+#if LEGACY_MODE
+                       : base (parent, caption, element)
+#endif
                {
                        HelpSource = hs;
+#if !LEGACY_MODE
                        rootNode = parent == null ? new Node (this, caption, element) : new Node (parent, caption, element);
+#endif
                }
 
                /// <summary>
@@ -96,21 +114,25 @@ namespace Monodoc
                        
                                using (BinaryWriter writer = new BinaryWriter (output, utf8)) {
                                        // Recursively dump
-                                       rootNode.Serialize (output, writer);
+                                       RootNode.Serialize (output, writer);
                                        // We want to generate 2.10 compatible files so we write the version number at the end
                                        writer.Write (VersionNumberKey);
                                        writer.Write (CurrentVersionNumber);
 
                                        output.Position = 0;
                                        writer.Write (new byte [] { (byte) 'M', (byte) 'o', (byte) 'H', (byte) 'P' });
-                                       writer.Write (rootNode.Address);
+                                       writer.Write (RootNode.Address);
                                }
                        }
                }
 
                public Node RootNode {
                        get {
+#if LEGACY_MODE
+                               return this;
+#else
                                return rootNode;
+#endif
                        }
                }
 
diff --git a/mcs/class/monodoc/Monodoc/Tree_Legacy.cs b/mcs/class/monodoc/Monodoc/Tree_Legacy.cs
deleted file mode 100644 (file)
index f55ceae..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-using System.IO;
-using System.Text;
-using System.Linq;
-using System.Xml;
-using System.Collections.Generic;
-
-namespace Monodoc
-{
-       public partial class Tree
-       {
-               [Obsolete ("Proxy to RootNode")]
-               public List<Node> Nodes {
-                       get {
-                               return RootNode.Nodes;
-                       }
-               }
-
-               [Obsolete ("Proxy to RootNode")]
-               public void Sort ()
-               {
-                       RootNode.Sort ();
-               }
-       }
-}
index c10937e357e28e958c9f059dd62eaf1f1e654e50..1dee0470816b6e9667888db2c1382d4935c1d6d4 100644 (file)
@@ -15,7 +15,6 @@ Monodoc/providers/EcmaDoc.cs
 Monodoc/HelpSource.cs
 Monodoc/HelpSource_Legacy.cs
 Monodoc/Tree.cs
-Monodoc/Tree_Legacy.cs
 Monodoc/Node.cs
 Monodoc/Node_Legacy.cs
 Monodoc/generator.cs