Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MemoryIndexTreeNode"/> class.
 /// </summary>
 /// <param name="parent">The parent.</param>
 /// <param name="index">The index.</param>
 public MemoryIndexTreeNode(MemoryIndexTreeNode parent = null, MemoryIndex index = null)
 {
     Index      = index;
     ParentNode = parent;
     AnyChild   = null;
     ChildNodes = new Dictionary <string, MemoryIndexTreeNode>();
 }
Example #2
0
 /// <summary>
 /// Gets the or create any branch.
 /// </summary>
 /// <returns>The tree node of the any branch.</returns>
 public MemoryIndexTreeNode GetOrCreateAny()
 {
     if (AnyChild == null)
     {
         AnyChild = new MemoryIndexTreeNode(this);
     }
     return(AnyChild);
 }
Example #3
0
        /// <summary>
        /// Gets the or create child with specified name.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns>Tree node which ontains the next segment identified by given name.</returns>
        public MemoryIndexTreeNode GetOrCreateChild(string name)
        {
            MemoryIndexTreeNode node = null;

            if (!ChildNodes.TryGetValue(name, out node))
            {
                node             = new MemoryIndexTreeNode(this);
                ChildNodes[name] = node;
            }
            return(node);
        }
Example #4
0
        /// <summary>
        /// Adds to root.
        /// </summary>
        /// <param name="index">The index.</param>
        /// <param name="root">The root.</param>
        private void addToRoot(MemoryIndex index, MemoryIndexTreeNode root)
        {
            MemoryIndexTreeNode node = root;

            foreach (IndexSegment segment in index.MemoryPath)
            {
                if (segment.IsAny)
                {
                    node = node.GetOrCreateAny();
                }
                else
                {
                    node = node.GetOrCreateChild(segment.Name);
                }
            }
            node.Index = index;
        }
Example #5
0
        /// <inheritdoc />
        public void VisitObjectIndex(ObjectIndex index)
        {
            MemoryIndexTreeNode root = null;

            if (!objectTreeRoots.TryGetValue(index.Object, out root))
            {
                root = new MemoryIndexTreeNode();
                objectTreeRoots[index.Object] = root;
            }

            if (index.MemoryRoot.IsAny)
            {
                addToRoot(index, root.GetOrCreateAny());
            }
            else
            {
                addToRoot(index, root.GetOrCreateChild(index.MemoryRoot.Name));
            }
        }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MemoryIndexTreeStackContext"/> class.
 /// </summary>
 public MemoryIndexTreeStackContext()
 {
     VariablesTreeRoot = new MemoryIndexTreeNode();
     ControlsTreeRoot  = new MemoryIndexTreeNode();
     TemporaryTreeRoot = new MemoryIndexTreeNode();
 }