示例#1
0
        /// <summary>
        /// Get a property node.
        /// </summary>
        /// <param name="path">The path of the node, relative to root.</param>
        /// <param name="create">true to create the node if it doesn't exist.</param>
        /// <returns>The node, or null if none exists and none was created.</returns>
        public PropertyNode GetNode(string path, bool create = false)
        {
            List <PathComponent> components = new List <PathComponent>();

            PathComponentUtis.ParsePath(path, components);
            return(FindNode(this, components, 0, create));
        }
示例#2
0
        /// <summary>
        /// Get a property node.
        /// </summary>
        /// <param name="relpath">The path of the node, relative to root.</param>
        /// <param name="create">true to create the node if it doesn't exist.</param>
        /// <returns>The node, or null if none exists and none was created.</returns>
        public PropertyNode GetNode(string relpath, int index, bool create = false)
        {
            List <PathComponent> components = new List <PathComponent>();

            PathComponentUtis.ParsePath(relpath, components);
            if (components.Count > 0)
            {
                components[components.Count - 1].index = index;
            }
            return(FindNode(this, components, 0, create));
        }
示例#3
0
 /// <summary>
 /// Protected constructor for making new nodes on demand.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="index"></param>
 /// <param name="parent"></param>
 protected PropertyNode(string name, int index, PropertyNode parent)
 {
     this.index  = index;
     this.name   = name;
     this.parent = parent;
     this.attr   = Attribute.READ | Attribute.WRITE;
     if (!PathComponentUtis.ValidateName(name))
     {
         throw new Exception("plain name expected instead of '" + name + '\'');
     }
 }