Ejemplo n.º 1
0
        private static int CompareKeyword(KKeywordInfo x, KKeywordInfo y)
        {
            string subX, subY;

            if (x.MainEntry != y.MainEntry)
            {
                return(String.Compare(x.MainEntry, y.MainEntry, StringComparison.OrdinalIgnoreCase));
            }

            subX = x.SubEntry;
            subY = y.SubEntry;

            if (subX == null)
            {
                subX = String.Empty;
            }

            if (subY == null)
            {
                subY = String.Empty;
            }

            if (subX != subY)
            {
                return(String.Compare(subX, subY, StringComparison.OrdinalIgnoreCase));
            }

            return(String.Compare(x.File, y.File, StringComparison.OrdinalIgnoreCase));
        }
Ejemplo n.º 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));
     }
 }
Ejemplo n.º 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);
                    }
                }
            }
        }
Ejemplo n.º 4
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(string filename)
        {
            XmlReaderSettings settings = new XmlReaderSettings();

            settings.ConformanceLevel = ConformanceLevel.Fragment;
            settings.IgnoreWhitespace = false;
            settings.IgnoreComments   = true;
            XmlReader reader = XmlReader.Create(filename, settings);

            //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";
            Regex r = new Regex(@",([^\)\>]+|([^\<\>]*\<[^\<\>]*\>[^\<\>]*)?|([^\(\)]*\([^\(\)]*\)[^\(\)]*)?)$");

            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")
                        {
                            KKeywordInfo kkwdinfo = new KKeywordInfo();
                            string       kkeyword = reader.GetAttribute("Term");
                            if (!string.IsNullOrEmpty(kkeyword))
                            {
                                kkeyword = ChmBuilder.ReplaceMarks(kkeyword);
                                Match match = r.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")
                    {
                        return;
                    }
                }
            }
        }
Ejemplo n.º 5
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(string filename)
        {
            XmlReaderSettings settings = new XmlReaderSettings();
            settings.ConformanceLevel = ConformanceLevel.Fragment;
            settings.IgnoreWhitespace = false;
            settings.IgnoreComments = true;
            XmlReader reader = XmlReader.Create(filename, settings);

            //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";
            Regex r = new Regex(@",([^\)\>]+|([^\<\>]*\<[^\<\>]*\>[^\<\>]*)?|([^\(\)]*\([^\(\)]*\)[^\(\)]*)?)$");

            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")
                        {
                            KKeywordInfo kkwdinfo = new KKeywordInfo();
                            string kkeyword = reader.GetAttribute("Term");
                            if (!string.IsNullOrEmpty(kkeyword))
                            {
                                kkeyword = ChmBuilder.ReplaceMarks(kkeyword);
                                Match match = r.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")
                        return;
                }
            }
        }
Ejemplo n.º 6
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);
             }
         }
     }
 }
Ejemplo n.º 7
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));
     }
 }
Ejemplo n.º 8
0
        private static int CompareKeyword(KKeywordInfo x, KKeywordInfo y)
        {
            string subX, subY;

            if(x.MainEntry != y.MainEntry)
                return String.Compare(x.MainEntry, y.MainEntry, StringComparison.OrdinalIgnoreCase);

            subX = x.SubEntry;
            subY = y.SubEntry;

            if(subX == null)
                subX = String.Empty;

            if(subY == null)
                subY = String.Empty;

            if(subX != subY)
                return String.Compare(subX, subY, StringComparison.OrdinalIgnoreCase);

            return String.Compare(x.File, y.File, StringComparison.OrdinalIgnoreCase);
        }