示例#1
0
        public override void ReadXml(XmlReader reader)
        {
            BuildExceptions.NotNull(reader, "reader");

            Debug.Assert(reader.NodeType == XmlNodeType.Element);

            if (reader.NodeType != XmlNodeType.Element)
            {
                return;
            }
            if (!String.Equals(reader.Name, TagName,
                               StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            string nodeText = reader.GetAttribute("id");

            if (ConceptualUtils.IsValidId(nodeText))
            {
                _topicId = nodeText;
            }
            nodeText = reader.GetAttribute("visible");
            if (!String.IsNullOrEmpty(nodeText))
            {
                _isVisible = Convert.ToBoolean(nodeText);
            }
            nodeText = reader.GetAttribute("revision");
            if (!String.IsNullOrEmpty(nodeText))
            {
                _revNumber = Convert.ToInt32(nodeText);
            }

            string      nodeName = null;
            XmlNodeType nodeType = XmlNodeType.None;

            while (reader.Read())
            {
                nodeName = reader.Name;
                nodeType = reader.NodeType;

                if (nodeType == XmlNodeType.Element)
                {
                    switch (nodeName)
                    {
                    case "title":
                        nodeText = reader.ReadString();
                        if (!String.IsNullOrEmpty(nodeText))
                        {
                            _topicTitle = nodeText;
                        }
                        break;

                    case "path":
                        if (_filePath == null)
                        {
                            _filePath = new BuildFilePath();
                        }
                        _filePath.ReadXml(reader);
                        break;

                    case "excludes":
                        this.OnReadExcludes(reader);
                        break;

                    case "metadata":
                        this.OnReadMetadata(reader);
                        break;

                    case "topic":
                        ConceptualItem topicItem = ConceptualItem.Create(
                            reader.GetAttribute("type"));
                        if (topicItem != null)
                        {
                            topicItem.Content = this.Content;
                            topicItem.BeginInit();
                            topicItem.ReadXml(reader);
                            topicItem.EndInit();

                            this.Add(topicItem);
                        }
                        break;

                    default:
                        this.OnReadXmlTag(reader);
                        break;
                    }
                }
                else if (nodeType == XmlNodeType.EndElement)
                {
                    if (String.Equals(nodeName, TagName,
                                      StringComparison.OrdinalIgnoreCase))
                    {
                        break;
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// This reads and sets its state or attributes stored in a <c>XML</c> format
        /// with the given reader.
        /// </summary>
        /// <param name="reader">
        /// The reader with which the <c>XML</c> attributes of this object are accessed.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// If the <paramref name="reader"/> is <see langword="null"/>.
        /// </exception>
        public override void ReadXml(XmlReader reader)
        {
            BuildExceptions.NotNull(reader, "reader");

            Debug.Assert(reader.NodeType == XmlNodeType.Element);
            if (reader.NodeType != XmlNodeType.Element)
            {
                return;
            }

            if (!String.Equals(reader.Name, TagName,
                               StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            _name = reader.GetAttribute("name");
            //_strongName = reader.GetAttribute("strongName");

            if (reader.IsEmptyElement)
            {
                return;
            }

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (String.Equals(reader.Name, "location",
                                      StringComparison.OrdinalIgnoreCase) &&
                        !reader.IsEmptyElement)
                    {
                        while (reader.Read())
                        {
                            if (reader.NodeType == XmlNodeType.Element)
                            {
                                if (String.Equals(reader.Name, BuildDirectoryPath.TagName,
                                                  StringComparison.OrdinalIgnoreCase))
                                {
                                    if (_path == null)
                                    {
                                        _path = new BuildFilePath();
                                    }
                                    _path.ReadXml(reader);
                                }
                            }
                            else if (reader.NodeType == XmlNodeType.EndElement)
                            {
                                if (String.Equals(reader.Name, "location",
                                                  StringComparison.OrdinalIgnoreCase))
                                {
                                    break;
                                }
                            }
                        }
                    }
                    else if (String.Equals(reader.Name, "redirection",
                                           StringComparison.OrdinalIgnoreCase))
                    {
                        string nodeText = reader.GetAttribute("enabled");
                        if (!String.IsNullOrEmpty(nodeText))
                        {
                            _isRedirected = Convert.ToBoolean(nodeText);
                        }

                        _redirectPublicKeyToken = reader.GetAttribute("publicKeyToken");

                        nodeText = reader.GetAttribute("version");
                        if (!String.IsNullOrEmpty(nodeText))
                        {
                            _redirectVersion = new Version(nodeText);
                        }

                        nodeText = reader.GetAttribute("culture");
                        if (!String.IsNullOrEmpty(nodeText))
                        {
                            _redirectCulture = new CultureInfo(nodeText);
                        }
                    }
                }
                else if (reader.NodeType == XmlNodeType.EndElement)
                {
                    if (String.Equals(reader.Name, TagName,
                                      StringComparison.OrdinalIgnoreCase))
                    {
                        break;
                    }
                }
            }
        }