Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14770/NHibernate/SqlCommand
Modified Files:
SqlString.cs
Log Message:
Added a Replace method for SQLExpression to use.
Index: SqlString.cs
===================================================================
RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/SqlString.cs,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** SqlString.cs 20 Aug 2004 15:26:24 -0000 1.12
--- SqlString.cs 26 Aug 2004 14:27:43 -0000 1.13
***************
*** 201,204 ****
--- 201,235 ----
}
+
+ /// <summary>
+ /// Replaces all occurrences of a specified <see cref="String"/> in this instance,
+ /// with another specified <see cref="String"/> .
+ /// </summary>
+ /// <param name="oldValue">A String to be replaced.</param>
+ /// <param name="newValue">A String to replace all occurrences of oldValue. </param>
+ /// <returns>
+ /// A new SqlString with oldValue replaced by the newValue. The new SqlString is
+ /// in the Compacted form.
+ /// </returns>
+ public SqlString Replace(string oldValue, string newValue)
+ {
+ // compacting returns a new SqlString object, so we are free to modify
+ // any of the parts because it has not been put in a hashtable so we can
+ // consider it mutable - there is no danger yet in changing the value that
+ // GetHashCode would return.
+ SqlString compacted = this.Compact();
+
+ for( int i=0; i<compacted.SqlParts.Length; i++ )
+ {
+ string sqlPart = compacted.SqlParts[i] as string;
+ if( sqlPart!=null )
+ {
+ compacted.SqlParts[i] = sqlPart.Replace( oldValue, newValue );
+ }
+ }
+
+ return compacted;
+ }
+
/// <summary>
/// Determines whether the beginning of this SqlString matches the specified System.String
|