Exemple #1
0
        /// <summary>
        /// Reads the node from the given reader.
        /// </summary>
        /// <param name="reader">The reader to read from.</param>
        /// <param name="openNodeAlreadyRead">Whether the opening of the node has already been read.</param>
        internal Node(PR0Reader reader, bool openNodeAlreadyRead)
        {
            if (!openNodeAlreadyRead)
            {
                reader.SkipWhiteSpace(reader.ReadChar());
            }
            // read the name of the node
            char current = reader.ReadNodeName(out name);

            if (current == PR0Constants.ASSIGN_CHARACTER) // the node has an identifying tag
            {
                current = reader.ReadAttributeValue(out tag);
            }

            current = reader.SkipWhiteSpace(current);

            while (current != PR0Constants.CLOSE_NODE_CHARCTER)
            {
                if (current == PR0Constants.OPEN_NODE_CHARCTER) // read a node
                {
                    children.AddLast(new Node(reader, true));
                    current = reader.ReadChar();
                }
                else // read an attribute
                {
                    string key;
                    string value;
                    current = reader.ReadAttribute(current, out key, out value);
                    attributes.Add(key, value);
                }
                current = reader.SkipWhiteSpace(current);
            }
        }
Exemple #2
0
        /// <summary>
        /// Loads a profile from the specified file and returns the root node.
        /// </summary>
        /// <param name="stream">The stream to load from.</param>
        /// <returns>The loaded Node.</returns>
        internal static Node Load(Stream stream)
        {
            var reader = new PR0Reader(stream);
            var node   = new Node(reader, false);

            reader.Close();
            return(node);
        }