image thumb extension fix

This commit is contained in:
WadeKallhoff
2013-06-19 18:11:28 +02:00
committed by Sebastiaan Janssen
parent e66306978a
commit a6768263d3
2 changed files with 31 additions and 1 deletions

View File

@@ -870,5 +870,34 @@ namespace Umbraco.Core
return alias;
}
/// <summary>
/// An extension method that returns a new string in which all occurrences of a
/// specified string in the current instance are replaced with another specified string.
/// StringComparison specifies the type of search to use for the specified string.
/// </summary>
/// <param name="source">Current instance of the string</param>
/// <param name="oldString">Specified string to replace</param>
/// <param name="newString">Specified string to inject</param>
/// <param name="stringComparison">String Comparison object to specify search type</param>
/// <returns>Updated string</returns>
public static string Replace(this string source, string oldString, string newString, StringComparison stringComparison)
{
var index = source.IndexOf(oldString, stringComparison);
// Determine if we found a match
var matchFound = index >= 0;
if (matchFound)
{
// Remove the old text
source = source.Remove(index, oldString.Length);
// Add the replacemenet text
source = source.Insert(index, newString);
}
return source;
}
}
}