Example #1
0
        /// <summary>
        /// Creates new child item and sets the name, but still do not add it. Used internally by <see cref="Add(String pathWithName)"/>
        /// </summary>
        /// <param name="nameForChild">The name for child.</param>
        /// <returns></returns>
        public virtual graphNodeCustom CreateChildItem(String nameForChild)
        {
            Type t = GetType();

            graphNodeCustom newChild = Activator.CreateInstance(t, new object[] { }) as graphNodeCustom;

            newChild.name = nameForChild;
            return(newChild);
        }
Example #2
0
        /// <summary>
        /// Returns the index of this node at its parent node. If no parent: returns -1
        /// </summary>
        /// <returns></returns>
        public Int32 GetIndex()
        {
            if (parent != null)
            {
                graphNodeCustom cParent = (graphNodeCustom)parent;

                return(cParent.mychildren.IndexOfValue(this));
            }
            else
            {
                return(-1);
            }
        }
Example #3
0
        /// <summary>
        /// Adds the specified path with name.
        /// </summary>
        /// <param name="pathWithName">Name of the path with.</param>
        /// <returns></returns>
        public virtual graphNodeCustom Add(String pathWithName)
        {
            List <String>   pathParts = pathWithName.SplitSmart(pathSeparator);
            graphNodeCustom head      = this;

            foreach (String part in pathParts)
            {
                head = head.CreateChildItem(part);
                Add(head);
                //head = head.Add(part);
            }

            return(head);
        }