ContentTreeItem[] IGetMembers.GetMembers(string category)
        {
            ContentTreeItem categoryItem = Find(category);

            if (categoryItem != null)
            {
                return(categoryItem.GetAllSubItem());
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// 生成命名空间页面
        /// </summary>
        /// <param name="typeItems">命名空间中的所有类型</param>
        /// <param name="ns">命名空间包含信息(名称,页面文件名等)</param>
        protected override void CreateNamespacePage(IGetTypes typeItems, ContentTreeItem ns)
        {
            HtmlText content = new HtmlText();

            foreach (string category in typeItems.GetAllCategory())
            {
                string   title      = NameToTitleDictionary[category] as string;
                HtmlText secContent = new HtmlText();
                foreach (ContentTreeItem typeItem in typeItems.GetMembers(category))
                {
                    Type             type = typeItem.Info as Type;
                    MemberXmlElement data = DataProvider.GetMemberXmlNode(type);
                    string           summary;
                    summary = GetChildNodeInnerText(data, "summary");
                    if (string.IsNullOrEmpty(summary))
                    {
                        summary = "&nbsp;";
                    }
                    string strRow = tempTypeTable_Row.Render(
                        tempImg.Render(NameToTitleDictionary[category], category + ".png"),
                        typeItem.FileName,
                        HtmlText.HtmlFormat(typeItem.Name),
                        summary
                        );
                    secContent.AppendPre(strRow);
                }
                content.AppendPre(CreateTableSection(title, title, secContent.ToString()));
            }

            Hashtable values = new Hashtable();

            values["CollapseAll"] = Resources.strCollapseAll;
            values["ExpandAll"]   = Resources.strExpandAll;
            values["PIC"]         = Resources.strPic;
            values["Title"]       = HtmlText.HtmlFormat(ns.Name);
            values["Summary"]     = "";
            values["Content"]     = content.ToString();
            values["Encoding"]    = TargetEncoding.HeaderName;
            tempPage.SaveAs(HtmlFileDirectory + "\\" + ns.FileName, TargetEncoding, values);
        }
 /// <summary>
 /// 添加一个子项
 /// </summary>
 /// <param name="item"></param>
 public void Add(ContentTreeItem item)
 {
     this._subItems.Add(item);
     item._parent = this;
 }
 /// <summary>
 /// 创建成员页面
 /// </summary>
 /// <param name="member">成员的信息</param>
 protected abstract void CreateMemberPage(ContentTreeItem member);
 /// <summary>
 /// 生成类型页面
 /// </summary>
 /// <param name="memberItems">该类型包含的所有成员</param>
 /// <param name="type">类型包含信息(名称,页面文件名等)</param>
 protected abstract void CreateTypePage(IGetMembers memberItems, ContentTreeItem type);
 /// <summary>
 /// 生成命名空间页面
 /// </summary>
 /// <param name="typeItems">命名空间中的所有类型</param>
 /// <param name="ns">命名空间包含信息(名称,页面文件名等)</param>
 protected abstract void CreateNamespacePage(IGetTypes typeItems, ContentTreeItem ns);
        /// <summary>
        /// 创建目录树,并确定命名空间,类型,成员对应的页面的文件名
        /// </summary>
        /// <returns></returns>
        private void CreateContentTree()
        {
            int pageCount = 0;

            foreach (Type type in DataProvider.GetSelectedTypes())
            {
                ContentTreeItem nsItem = null, typeParentItem = null;
                string          typeParentName = "";
                nsItem = _root.Find(type.Namespace);
                if (nsItem == null)
                {
                    string nsPageFileName = (++pageCount).ToString("000000") + Resources.Extension;
                    _root.Add(nsItem = new ContentTreeItem(type.Namespace, nsPageFileName));
                    if (!string.IsNullOrEmpty(type.Namespace))
                    {
                        _namespaceFileName.Add(type.Namespace, nsPageFileName);
                    }
                }
                if (type.IsClass)
                {
                    typeParentName = "Class";
                }
                else if (type.IsEnum)
                {
                    typeParentName = "Enumeration";
                }
                else if (type.IsValueType)
                {
                    typeParentName = "Structure";
                }
                else if (type.IsInterface)
                {
                    typeParentName = "Interface";
                }
                else
                {
                    typeParentName = "Delegate";
                }
                typeParentItem = nsItem.Find(typeParentName);
                if (typeParentItem == null)
                {
                    nsItem.Add(typeParentItem = new ContentTreeItem(typeParentName, ""));
                }
                ContentTreeItem typeItem = new ContentTreeItem(DocumentBuilderUtility.GetTypeDefinition(type, false), (++pageCount).ToString("000000") + Resources.Extension, type);
                _memberFileName.Add(DocumentBuilderUtility.GetMemberID(type), typeItem.FileName);
                typeParentItem.Add(typeItem);
                foreach (MemberInfo memberInfo in DataProvider.GetTypeSelectedMembers(type))
                {
                    string parentItemName = "";
                    #region 添加成员
                    switch (memberInfo.MemberType)
                    {
                    case MemberTypes.Constructor:
                    {
                        parentItemName = "Constructor";
                        break;
                    }

                    case MemberTypes.Method:
                    {
                        MethodInfo method = memberInfo as MethodInfo;
                        if (!method.IsSpecialName)
                        {
                            if (method.IsPublic)
                            {
                                parentItemName = "PublicMethod";
                            }
                            else if (method.IsPrivate)
                            {
                                parentItemName = "PrivateMethod";
                            }
                            else
                            {
                                parentItemName = "ProtectedMethod";
                            }
                        }
                        break;
                    }

                    case MemberTypes.Field:
                    {
                        FieldInfo field = memberInfo as FieldInfo;
                        if (field.IsPublic)
                        {
                            parentItemName = "PublicField";
                        }
                        else if (field.IsPrivate)
                        {
                            parentItemName = "PrivateField";
                        }
                        else
                        {
                            parentItemName = "ProtectedField";
                        }
                        break;
                    }

                    case MemberTypes.Property:
                    {
                        PropertyInfo property = memberInfo as PropertyInfo;
                        MethodInfo   pm       = property.GetGetMethod(true);
                        if (pm == null)
                        {
                            pm = property.GetSetMethod(true);
                        }
                        if (pm != null)
                        {
                            if (pm.IsPublic)
                            {
                                parentItemName = "PublicProperty";
                            }
                            else if (pm.IsPrivate)
                            {
                                parentItemName = "PrivateProperty";
                            }
                            else
                            {
                                parentItemName = "ProtectedProperty";
                            }
                        }
                        break;
                    }

                    case MemberTypes.Event:
                    {
                        parentItemName = "Event";
                        break;
                    }
                    }
                    if (!string.IsNullOrEmpty(parentItemName))
                    {
                        ContentTreeItem parentItem = typeItem.Find(parentItemName);
                        if (parentItem == null)
                        {
                            parentItem = new ContentTreeItem(parentItemName, typeItem.FileName + "#" + parentItemName);
                            typeItem.Add(parentItem);
                        }
                        if (memberInfo.MemberType == MemberTypes.Constructor)
                        {
                            string fileName = (++pageCount).ToString("000000") + Resources.Extension;
                            parentItem.Add(new ContentTreeItem(DocumentBuilderUtility.GetTypeDefinition(memberInfo.ReflectedType, false), fileName, memberInfo));
                        }
                        else
                        {
                            string fileName = _memberFileName[DocumentBuilderUtility.GetMemberID(memberInfo)] as string;
                            if (string.IsNullOrEmpty(fileName))
                            {
                                fileName = (++pageCount).ToString("000000") + Resources.Extension;
                                _memberFileName.Add(DocumentBuilderUtility.GetMemberID(memberInfo), fileName);
                            }
                            parentItem.Add(new ContentTreeItem(memberInfo.Name, fileName, memberInfo));
                        }
                    }
                    #endregion
                }
            }
            _root.Sort();
            _total = pageCount;
        }
        /// <summary>
        /// 创建成员页面
        /// </summary>
        /// <param name="memberItem">成员的信息</param>
        protected override void CreateMemberPage(ContentTreeItem memberItem)
        {
            MemberInfo       info       = memberItem.Info;
            MemberXmlElement memberData = DataProvider.GetMemberXmlNode(info);

            HtmlText content = new HtmlText();
            int      secID   = 0;

            foreach (PageSection section in MemberPageSections)
            {
                string secText = null;
                switch (section.SectionType)
                {
                case PageSectionType.Syntax:
                {
                    string parameters = "";
                    string ret        = "";
                    string val        = "";

                    if (memberData != null)
                    {
                        XmlNodeList ns;

                        ns = memberData.Data.GetElementsByTagName("param");
                        foreach (XmlElement p in ns)
                        {
                            parameters += tempParam.Render(
                                HtmlText.HtmlFormat(p.GetAttribute("name")),
                                GetInnerTags(p, memberData.Owner)
                                );
                        }

                        ret = GetChildNodeInnerText(memberData, "returns");
                        val = GetChildNodeInnerText(memberData, "value");
                    }

                    HtmlText secContent = new HtmlText(), declaration = new HtmlText();

                    declaration.AppendPre(HtmlText.HtmlFormat(CreateMemberDeclaration(info, memberData)));

                    secContent.AppendPre(tempDeclaration.Render("C#", declaration));

                    switch (info.MemberType)
                    {
                    case MemberTypes.Constructor:
                    case MemberTypes.Method:
                    {
                        if (!string.IsNullOrEmpty(parameters))
                        {
                            secContent.AppendPre(tempParamsBlock.Render(Resources.String46, parameters));
                        }
                        if (!string.IsNullOrEmpty(ret))
                        {
                            secContent.AppendPre(tempParamsBlock.Render(Resources.String47, ret));
                        }
                        break;
                    }

                    case MemberTypes.Property:
                    {
                        if (!string.IsNullOrEmpty(val))
                        {
                            secContent.AppendPre(tempParamsBlock.Render(Resources.String48, val));
                        }
                        break;
                    }

                    default:
                        break;
                    }

                    Hashtable sectionValues = new Hashtable();
                    sectionValues["ID"]      = "Syntex";
                    sectionValues["Title"]   = section.Name;
                    sectionValues["Content"] = secContent.ToString();
                    secText = tempSection.Render(sectionValues);
                    break;
                }

                case PageSectionType.Remarks:
                {
                    if (memberData != null)
                    {
                        string remarks = GetChildNodeInnerText(memberData, "remarks");
                        if (!string.IsNullOrEmpty(remarks))
                        {
                            Hashtable sectionValues = new Hashtable();
                            sectionValues["ID"]      = "Remarks";
                            sectionValues["Title"]   = section.Name;
                            sectionValues["Content"] = tempRemarks.Render(remarks);
                            secText = tempSection.Render(sectionValues);
                        }
                    }
                    break;
                }

                case PageSectionType.Exception:
                {
                    if (memberData != null)
                    {
                        XmlNodeList ns;
                        ns = memberData.Data.GetElementsByTagName("exception");
                        HtmlText ecx = new HtmlText();
                        foreach (XmlElement n in ns)
                        {
                            int index = n.GetAttribute("cref").LastIndexOfAny(new char[] { ':', '.', '+' });
                            ecx.AppendPre(
                                tempExceptionTable_Row.Render(
                                    n.GetAttribute("cref").Substring(index + 1),
                                    n.InnerText
                                    )
                                );
                        }
                        if (ecx.Length > 0)
                        {
                            Hashtable sectionValues = new Hashtable();
                            sectionValues["ID"]      = "Exception";
                            sectionValues["Title"]   = section.Name;
                            sectionValues["Content"] = tempExceptionTable.Render(ecx);
                            secText = tempSection.Render(sectionValues);
                        }
                    }
                    break;
                }

                case PageSectionType.Example:
                {
                    if (memberData != null)
                    {
                        string exampleText = GetChildNodeInnerText(memberData, "example");
                        if (!string.IsNullOrEmpty(exampleText))
                        {
                            Hashtable sectionValues = new Hashtable();
                            sectionValues["ID"]      = "Exception";
                            sectionValues["Title"]   = section.Name;
                            sectionValues["Content"] = exampleText;
                            secText = tempSection.Render(sectionValues);
                        }
                    }
                    break;
                }

                case PageSectionType.FromXML:
                {
                    if (memberData != null)
                    {
                        string text = GetChildNodeInnerText(memberData, section.XmlSource);
                        if (!string.IsNullOrEmpty(text))
                        {
                            Hashtable sectionValues = new Hashtable();
                            sectionValues["ID"]      = "SEC" + secID.ToString("00");
                            sectionValues["Title"]   = section.Name;
                            sectionValues["Content"] = text;
                            secText = tempSection.Render(sectionValues);
                        }
                    }
                    break;
                }
                }
                if (!string.IsNullOrEmpty(secText))
                {
                    content.AppendPre(secText);
                }
                secID++;
            }

            string summary = GetChildNodeInnerText(memberData, "summary");

            Hashtable values = new Hashtable();

            values["CollapseAll"] = Resources.strCollapseAll;
            values["ExpandAll"]   = Resources.strExpandAll;
            values["PIC"]         = Resources.strPic;
            if (info.MemberType == MemberTypes.Constructor)
            {
                values["Title"] = HtmlText.HtmlFormat(memberItem.Name) + " " + NameToTypeDictionary[memberItem.Parent.Name];
            }
            else
            {
                values["Title"] = HtmlText.HtmlFormat(info.DeclaringType.Name + "." + info.Name) + " " + NameToTypeDictionary[memberItem.Parent.Name];
            }
            values["Summary"]  = summary;
            values["Content"]  = content;
            values["Encoding"] = TargetEncoding.HeaderName;

            tempPage.SaveAs(
                HtmlFileDirectory + "\\" + memberItem.FileName,
                TargetEncoding,
                values
                );
        }
        /// <summary>
        /// 生成类型页面
        /// </summary>
        /// <param name="memberItems">该类型包含的所有成员</param>
        /// <param name="typeItem">类型包含信息(名称,页面文件名等)</param>
        protected override void CreateTypePage(IGetMembers memberItems, ContentTreeItem typeItem)
        {
            HtmlText pageContent = new HtmlText();
            Type     type        = typeItem.Info as Type;

            MemberXmlElement typeData = DataProvider.GetMemberXmlNode(type);
            int secID = 0;

            foreach (PageSection section in TypePageSections)
            {
                string secText = null;
                switch (section.SectionType)
                {
                case PageSectionType.Constructor:
                    secText = GetTypeMemberCategorySection(memberItems, type, typeData, "Constructor");
                    break;

                case PageSectionType.PublicMethod:
                    secText = GetTypeMemberCategorySection(memberItems, type, typeData, "PublicMethod");
                    break;

                case PageSectionType.ProtectedMethod:
                    secText = GetTypeMemberCategorySection(memberItems, type, typeData, "ProtectedMethod");
                    break;

                case PageSectionType.PrivateMethod:
                    secText = GetTypeMemberCategorySection(memberItems, type, typeData, "PrivateMethod");
                    break;

                case PageSectionType.PublicProperty:
                    secText = GetTypeMemberCategorySection(memberItems, type, typeData, "PublicProperty");
                    break;

                case PageSectionType.ProtectedProperty:
                    secText = GetTypeMemberCategorySection(memberItems, type, typeData, "ProtectedProperty");
                    break;

                case PageSectionType.PrivateProperty:
                    secText = GetTypeMemberCategorySection(memberItems, type, typeData, "PrivateProperty");
                    break;

                case PageSectionType.PublicField:
                    secText = GetTypeMemberCategorySection(memberItems, type, typeData, "PublicField");
                    break;

                case PageSectionType.ProtectedField:
                    secText = GetTypeMemberCategorySection(memberItems, type, typeData, "ProtectedField");
                    break;

                case PageSectionType.PrivateField:
                    secText = GetTypeMemberCategorySection(memberItems, type, typeData, "PrivateField");
                    break;

                case PageSectionType.Event:
                    secText = GetTypeMemberCategorySection(memberItems, type, typeData, "Event");
                    break;

                case PageSectionType.Remarks:
                {
                    if (typeData != null)
                    {
                        HtmlText remarks = new HtmlText();
                        remarks.AppendPre(GetChildNodeInnerText(typeData, "remarks"));
                        if (remarks.Length > 0)
                        {
                            Hashtable sectionValues = new Hashtable();
                            sectionValues["ID"]      = "remarks";
                            sectionValues["Title"]   = Resources.String42;
                            sectionValues["Content"] = tempRemarks.Render(remarks);
                            secText = tempSection.Render(sectionValues);
                        }
                    }
                    break;
                }

                case PageSectionType.Example:
                {
                    if (typeData != null)
                    {
                        HtmlText example = new HtmlText();
                        example.AppendPre(GetChildNodeInnerText(typeData, "example"));
                        if (example.Length > 0)
                        {
                            Hashtable sectionValues = new Hashtable();
                            sectionValues["ID"]      = "example";
                            sectionValues["Title"]   = Resources.String43;
                            sectionValues["Content"] = tempRemarks.Render(example);
                            secText = tempSection.Render(sectionValues);
                        }
                    }
                    break;
                }

                case PageSectionType.FromXML:
                {
                    if (typeData != null)
                    {
                        string text = GetChildNodeInnerText(typeData, section.XmlSource);
                        if (!string.IsNullOrEmpty(text))
                        {
                            Hashtable sectionValues = new Hashtable();
                            sectionValues["ID"]      = "SEC" + secID.ToString("00");
                            sectionValues["Title"]   = section.Name;
                            sectionValues["Content"] = text;
                            secText = tempSection.Render(sectionValues);
                        }
                    }
                    break;
                }
                }
                if (!string.IsNullOrEmpty(secText))
                {
                    pageContent.AppendPre(secText);
                }
                secID++;
            }

            Hashtable values = new Hashtable();

            values["CollapseAll"] = Resources.strCollapseAll;
            values["ExpandAll"]   = Resources.strExpandAll;
            values["PIC"]         = Resources.strPic;
            values["Title"]       = HtmlText.HtmlFormat(DocumentBuilderUtility.GetTypeDefinition(type, false)) + " " + NameToTypeDictionary[typeItem.Parent.Name];
            values["Summary"]     = GetChildNodeInnerText(typeData, "summary");
            values["Content"]     = pageContent;
            values["Encoding"]    = TargetEncoding.HeaderName;
            tempPage.SaveAs(
                HtmlFileDirectory + "\\" + typeItem.FileName,
                TargetEncoding,
                values
                );
        }