GetEnumerator() public méthode

public GetEnumerator ( ) : System.Collections.IEnumerator
Résultat System.Collections.IEnumerator
Exemple #1
0
 public TextHighlighter(
     Page page,
     MatchCollection matches
     )
 {
     this.page = page;
     this.matchEnumerator = matches.GetEnumerator();
 }
Exemple #2
0
 public object FormatMatches(MatchCollection matches)
 {
     string[] strArray;
     if ((matches == null) || (matches.Count == 0))
     {
         return null;
     }
     List<object> elements = new List<object>();
     int startIndex = 0;
     using (IEnumerator enumerator = matches.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             Match current = (Match) enumerator.Current;
             string str = this.Text.Substring(startIndex, current.Index - startIndex).Replace("\t", " ").Replace("\r", "");
             if (str.Length > 0)
             {
                 strArray = str.Split(new char[] { '\n' }).Select<string, string>(((Func<string, int, string>) ((l, n) => ((n == 0) ? l : l.TrimStart(new char[0]))))).ToArray<string>();
                 if ((strArray.Length > 4) && (startIndex > 0))
                 {
                     strArray = strArray.Take<string>(2).Concat<string>("...".Split(new char[0])).Concat<string>(strArray.Skip<string>((strArray.Length - 2)).Take<string>(2)).ToArray<string>();
                 }
                 else if ((strArray.Length > 2) && (startIndex == 0))
                 {
                     strArray = strArray.Skip<string>((strArray.Length - 2)).Take<string>(2).ToArray<string>();
                     if (strArray.First<string>().Trim().Length == 0)
                     {
                         strArray = strArray.Skip<string>(1).ToArray<string>();
                     }
                 }
                 elements.Add(string.Join("\r\n", strArray));
             }
             elements.Add(Util.Highlight(current.Value));
             startIndex = current.Index + current.Length;
             if (elements.Count > 6)
             {
                 goto Label_01B9;
             }
         }
         goto Label_01E8;
     Label_01B9:
         elements.Add("...");
         return Util.WordRun(false, elements);
     }
 Label_01E8:
     if (startIndex < this.Text.Length)
     {
         strArray = this.Text.Substring(startIndex).Replace("\t", " ").Replace("\r", "").Split(new char[] { '\n' }).Select<string, string>(((Func<string, int, string>) ((l, n) => ((n == 0) ? l : l.TrimStart(new char[0]))))).ToArray<string>();
         elements.Add(string.Join("\r\n", strArray.Take<string>(2).ToArray<string>()));
     }
     return Util.WordRun(false, elements);
 }
 static public int GetEnumerator(IntPtr l)
 {
     try {
         System.Text.RegularExpressions.MatchCollection self = (System.Text.RegularExpressions.MatchCollection)checkSelf(l);
         var ret = self.GetEnumerator();
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }