示例#1
0
        /// <summary>
        /// As XmlReader is forward only and we added support for leaving xmlisland data.
        /// We have to use another xmlreader to find TocTile, keywords etc.
        /// </summary>
        /// <param name="filename"></param>
        private void ReadXmlIsland(XmlReader reader)
        {
            //Fix TFS bug 289403: search if there is comma in k keyword except those in () or <>.
            //sample1: "StoredNumber (T1,T2) class, about StoredNumber (T1,T2) class";
            //sample2: "StoredNumber <T1,T2> class, about StoredNumber <T1,T2> class";

            while (reader.Read())
            {
                if (reader.IsStartElement())
                {
                    if (reader.Name.ToLower() == "mshelp:toctitle")
                    {
                        string titleAttr = reader.GetAttribute("Title");
                        if (!String.IsNullOrEmpty(titleAttr))
                        {
                            _currentTitle = titleAttr;
                        }
                    }

                    if (reader.Name.ToLower() == "mshelp:keyword")
                    {
                        string indexType = reader.GetAttribute("Index");
                        if (indexType == "K")
                        {
                            string kkeyword = reader.GetAttribute("Term");
                            if (!string.IsNullOrEmpty(kkeyword))
                            {
                                KKeywordInfo kkwdinfo = new KKeywordInfo();
                                kkeyword = FormatChmHelper.ReplaceMarks(kkeyword);
                                Match match = _regEx.Match(kkeyword);
                                if (match.Success)
                                {
                                    kkwdinfo.MainEntry = kkeyword.Substring(0,
                                                                            match.Index);
                                    kkwdinfo.SubEntry = kkeyword.Substring(
                                        match.Index + 1).TrimStart(new char[] { ' ' });
                                }
                                else
                                {
                                    kkwdinfo.MainEntry = kkeyword;
                                }

                                kkwdinfo.File = _currentFile;
                                _kkeywords.Add(kkwdinfo);
                            }
                        }
                    }
                }

                if (reader.NodeType == XmlNodeType.EndElement)
                {
                    if (reader.Name == "xml")
                    {
                        break;
                    }
                }
            }
        }
示例#2
0
 private static int CompareKeyword(KKeywordInfo x, KKeywordInfo y)
 {
     if (x.MainEntry != y.MainEntry)
     {
         return(x.MainEntry.CompareTo(y.MainEntry));
     }
     else
     {
         string s1 = x.SubEntry;
         string s2 = y.SubEntry;
         if (s1 == null)
         {
             s1 = String.Empty;
         }
         if (s2 == null)
         {
             s2 = String.Empty;
         }
         return(s1.CompareTo(s2));
     }
 }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        private void InsertSeealsoIndice()
        {
            _kkwdTable.Sort(CompareKeyword);
            string lastMainEntry = String.Empty;

            for (int i = 0; i < _kkwdTable.Count; i++)
            {
                if (!string.IsNullOrEmpty(_kkwdTable[i].SubEntry))
                {
                    if (i > 0)
                    {
                        lastMainEntry = _kkwdTable[i - 1].MainEntry;
                    }
                    if (lastMainEntry != _kkwdTable[i].MainEntry)
                    {
                        KKeywordInfo seealso = new KKeywordInfo();
                        seealso.MainEntry = _kkwdTable[i].MainEntry;
                        _kkwdTable.Insert(i, seealso);
                    }
                }
            }
        }