Exemplo n.º 1
0
 /// <summary>
 /// Appends a single part, including (useless) optimizations
 /// </summary>
 /// <param name="parts"></param>
 /// <param name="index"></param>
 /// <param name="part"></param>
 public static void InsertPart(IList<SqlPart> parts, int index, SqlPart part)
 {
     // optimization if top part is a literal, and the one we're adding is a literal too
     // in this case, we combine both
     // (this is useless, just pretty)
     if (part is SqlLiteralPart && index > 0 && parts[index - 1] is SqlLiteralPart)
     {
         parts[index - 1] = new SqlLiteralPart(parts[index - 1].Sql + part.Sql);
     }
     else
         parts.Insert(index, part);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Appends a single part, including (useless) optimizations
 /// </summary>
 /// <param name="parts"></param>
 /// <param name="index"></param>
 /// <param name="part"></param>
 public static void InsertPart(IList <SqlPart> parts, int index, SqlPart part)
 {
     // optimization if top part is a literal, and the one we're adding is a literal too
     // in this case, we combine both
     // (this is useless, just pretty)
     if (part is SqlLiteralPart && index > 0 && parts[index - 1] is SqlLiteralPart)
     {
         parts[index - 1] = new SqlLiteralPart(parts[index - 1].Sql + part.Sql);
     }
     else
     {
         parts.Insert(index, part);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Replaces the specified text, optionally ignoring the case.
 /// The method does not replace cross-parts text
 /// </summary>
 /// <param name="oldText">The old text.</param>
 /// <param name="newText">The new text.</param>
 /// <param name="ignoreCase">if set to <c>true</c> [ignore case].</param>
 public void Replace(string oldText, string newText, bool ignoreCase)
 {
     for (int partIndex = 0; partIndex < Parts.Count; partIndex++)
     {
         var part = Parts[partIndex];
         if (part.Sql.ContainsCase(oldText, ignoreCase))
         {
             // we know how to process only on literal strings
             if (part is SqlLiteralPart)
             {
                 Parts[partIndex] = new SqlLiteralPart(part.Sql.ReplaceCase(oldText, newText, ignoreCase));
             }
         }
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Replaces the specified text, optionally ignoring the case.
 /// The method does not replace cross-parts text
 /// </summary>
 /// <param name="oldText">The old text.</param>
 /// <param name="newText">The new text.</param>
 /// <param name="ignoreCase">if set to <c>true</c> [ignore case].</param>
 public void Replace(string oldText, string newText, bool ignoreCase)
 {
     for (int partIndex = 0; partIndex < Parts.Count; partIndex++)
     {
         var part = Parts[partIndex];
         if (part.Sql.ContainsCase(oldText, ignoreCase))
         {
             // we know how to process only on literal strings
             if (part is SqlLiteralPart)
             {
                 Parts[partIndex] = new SqlLiteralPart(part.Sql.ReplaceCase(oldText, newText, ignoreCase));
             }
         }
     }
 }