示例#1
0
文件: Topic.cs 项目: wholroyd/SHFB
        //=====================================================================

        /// <summary>
        /// This is used to load the topic information from the project file
        /// </summary>
        /// <param name="xr">The XML text reader from which the information is loaded</param>
        internal void ReadXml(XmlReader xr)
        {
            Topic  newTopic;
            string guid, parentMode;
            bool   visible, attrValue;

            guid = xr.GetAttribute("id");

            if (guid != null && guid.Trim().Length != 0)
            {
                contentId = guid;
            }
            else
            {
                contentId = Guid.NewGuid().ToString();
            }

            if (!Boolean.TryParse(xr.GetAttribute("noFile"), out noFile))
            {
                noFile = false;
            }

            if (!Boolean.TryParse(xr.GetAttribute("visible"), out visible))
            {
                visible = true;
            }

            if (Boolean.TryParse(xr.GetAttribute("isDefault"), out attrValue))
            {
                this.IsDefaultTopic = attrValue;
            }

            if (Boolean.TryParse(xr.GetAttribute("isMSHVRoot"), out attrValue))
            {
                this.IsMSHVRootContentContainer = attrValue;
            }

            if (Boolean.TryParse(xr.GetAttribute("isExpanded"), out attrValue))
            {
                this.IsExpanded = attrValue;
            }

            if (Boolean.TryParse(xr.GetAttribute("isSelected"), out attrValue))
            {
                this.IsSelected = attrValue;
            }

            parentMode = xr.GetAttribute("apiParentMode");

            if (!String.IsNullOrEmpty(parentMode))
            {
                this.ApiParentMode = (ApiParentMode)Enum.Parse(typeof(ApiParentMode), parentMode, true);
            }

            this.Visible  = visible;
            this.Title    = xr.GetAttribute("title");
            this.TocTitle = xr.GetAttribute("tocTitle");
            this.LinkText = xr.GetAttribute("linkText");

            if (!xr.IsEmptyElement)
            {
                while (!xr.EOF)
                {
                    xr.Read();

                    if (xr.NodeType == XmlNodeType.EndElement && xr.Name == "Topic")
                    {
                        break;
                    }

                    if (xr.NodeType == XmlNodeType.Element)
                    {
                        if (xr.Name == "HelpAttributes")
                        {
                            helpAttributes.ReadXml(xr);
                        }
                        else
                        if (xr.Name == "HelpKeywords")
                        {
                            keywords.ReadXml(xr);
                        }
                        else
                        if (xr.Name == "Topic")
                        {
                            newTopic = new Topic();
                            newTopic.ReadXml(xr);
                            this.Subtopics.Add(newTopic);
                        }
                    }
                }
            }
        }