Apply() public static méthode

Apply the given patch string diff to the given string dest
public static Apply ( StringBuilder dest, string diff ) : void
dest StringBuilder Destination string
diff string Patch string
Résultat void
Exemple #1
0
 private static void AssertTrie(Trie trie, string file, bool usefull,
                                bool storeorig)
 {
     using (TextReader @in =
                new StreamReader(new FileStream(file, FileMode.Open), Encoding.UTF8))
     {
         for (string line = @in.ReadLine(); line != null; line = @in.ReadLine())
         {
             try
             {
                 line = line.ToLowerInvariant();
                 StringTokenizer st = new StringTokenizer(line);
                 st.MoveNext();
                 string stem = st.Current;
                 if (storeorig)
                 {
                     string cmd = (usefull) ? trie.GetFully(stem) : trie
                                  .GetLastOnPath(stem);
                     StringBuilder stm = new StringBuilder(stem);
                     Diff.Apply(stm, cmd);
                     assertEquals(stem.ToLowerInvariant(), stm.ToString().ToLowerInvariant());
                 }
                 while (st.MoveNext())
                 {
                     string token = st.Current;
                     if (token.Equals(stem, StringComparison.Ordinal))
                     {
                         continue;
                     }
                     string cmd = (usefull) ? trie.GetFully(token) : trie
                                  .GetLastOnPath(token);
                     StringBuilder stm = new StringBuilder(token);
                     Diff.Apply(stm, cmd);
                     assertEquals(stem.ToLowerInvariant(), stm.ToString().ToLowerInvariant());
                 }
             }
             catch (InvalidOperationException /*x*/)
             {
                 // no base token (stem) on a line
             }
         }
     }
 }
Exemple #2
0
 private static void AssertTrie(Trie trie, string file, bool usefull,
                                bool storeorig)
 {
     using TextReader @in = new StreamReader(new FileStream(file, FileMode.Open), Encoding.UTF8);
     for (string line = @in.ReadLine(); line != null; line = @in.ReadLine())
     {
         line = line.ToLowerInvariant();
         using StringTokenizer st = new StringTokenizer(line);
         if (st.MoveNext())
         {
             string stem = st.Current;
             if (storeorig)
             {
                 string cmd = (usefull) ? trie.GetFully(stem) : trie
                              .GetLastOnPath(stem);
                 StringBuilder stm = new StringBuilder(stem);
                 Diff.Apply(stm, cmd);
                 assertEquals(stem.ToLowerInvariant(), stm.ToString().ToLowerInvariant());
             }
             while (st.MoveNext())
             {
                 string token = st.Current;
                 if (token.Equals(stem, StringComparison.Ordinal))
                 {
                     continue;
                 }
                 string cmd = (usefull) ? trie.GetFully(token) : trie
                              .GetLastOnPath(token);
                 StringBuilder stm = new StringBuilder(token);
                 Diff.Apply(stm, cmd);
                 assertEquals(stem.ToLowerInvariant(), stm.ToString().ToLowerInvariant());
             }
         }
         else // LUCENENET: st.MoveNext() will return false rather than throwing a NoSuchElementException
         {
             // no base token (stem) on a line
         }
     }
 }