Ejemplo n.º 1
0
        /// <summary>
        /// Adds a child entry with the specified name of the specified type.
        /// </summary>
        public FileTableEntry AddChild(string name, EntryType type)
        {
            // See if the entry already exists in this node's children
            if (ParentEntry != null)
            {
                List <FileTableEntry> entries = GetChildren(new NameFilter(name));
                if (entries.Count > 0)
                {
                    return(entries[0]);
                }
            }

            // Creat the new entry and assign it's values.
            FileTableEntry newNode = CreateEntry(type);

            newNode.ParentEntry = this;
            newNode.Name        = name;

            // If this is the first child of this entry, set the reference.
            if (ChildEntry == null)
            {
                ChildEntry = newNode;
            }
            else
            {
                // If not, set it up as a sibling to the existing child.
                ChildEntry.AddSibling(newNode);
            }
            return(newNode);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds a new sibling to the node.
 /// </summary>
 public void AddSibling(FileTableEntry newSibling)
 {
     // TODO: Verify that the sibling doesnt already exist.
     // (Do this the same way that AddChild does)
     if (SiblingEntry == null)
     {
         newSibling.PreviousSiblingEntry = this;
         SiblingEntry = newSibling;
     }
     else
     {
         SiblingEntry.AddSibling(newSibling);
     }
 }