Пример #1
0
        /// <summary>
        /// Add a subnode to this node
        /// </summary>
        /// <param name="inName">Name of the new Node</param>
        /// <returns>The newly created node</returns>
        public stringNode AddNode(string inName)
        {
            stringNode newStrNode = new stringNode(inName);

            Nodes.Add(newStrNode);
            newStrNode.Parent = this;
            return(newStrNode);
        }
Пример #2
0
        /// <summary>
        /// Add a subnode to this node
        /// </summary>
        /// <param name="inName">Name of the new Node</param>
        /// <param name="inDesc">Description of the new Node</param>
        /// <returns>The newly created node</returns>
        public stringNode AddNode(string inName, string inDesc)
        {
            stringNode newStrNode = new stringNode(inName);

            newStrNode.Description = inDesc;
            Nodes.Add(newStrNode);
            newStrNode.Parent = this;
            return(newStrNode);
        }
Пример #3
0
        /// <summary>
        /// Add a subnode to this node
        /// </summary>
        /// <param name="inChild">the child to add</param>
        public void AddNode(stringNode inChild)
        {
            if (inChild.Parent != null)
            {
                inChild.Parent.Nodes.Remove(inChild);
            }

            Nodes.Add(inChild);
            inChild.Parent = this;
        }
Пример #4
0
        public string GetFullName(bool useRoot)
        {
            string fullName = Name;

            stringNode parent = Parent;

            while (parent != null && (parent.Parent != null || useRoot))
            {
                fullName = parent.Name + "\\" + fullName;
                parent   = parent.Parent;
            }

            return(fullName);
        }
Пример #5
0
        public bool IsChildOf(stringNode realDropped)
        {
            foreach (stringNode node in realDropped.Nodes)
            {
                if (this == node)
                {
                    return(true);
                }
                else
                {
                    if (IsChildOf(node))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Пример #6
0
        // == METHODS =====================================================================

        public stringNode AddPath(string value)
        {
            string[] splittedValues = value.Split('/');

            stringNode parentNode = this;
            stringNode node       = null;

            foreach (string splittedValue in splittedValues)
            {
                node = parentNode.Get(splittedValue);
                if (node == null)
                {
                    node = parentNode.AddNode(splittedValue);
                }

                parentNode = node;
            }

            return(node);
        }
Пример #7
0
        public bool RemovePath(string value)
        {
            string[] splittedValues = value.Split('/');

            stringNode parentNode = this;
            stringNode node       = null;

            foreach (string splittedValue in splittedValues)
            {
                node = parentNode.Get(splittedValue);
                if (node != null)
                {
                    parentNode = node;
                }
            }

            if (node != null)
            {
                node.Parent.Nodes.Remove(node);
                return(true);
            }

            return(false);
        }