Added tests for dynamic node to select children based on the child doc type names including pluralized names and added

support for checking with case insensitivity. Example. CurrentPage.NewsItems where NewsItem is a child doc type alias.
Found one reason why the old dynamic node has performance issues and have added a note, just need to do more reseearch to
make sure my findings are correct.
Changed over all of the new DynamicNode classes to be DynamicDocument instead.
This commit is contained in:
Shannon Deminick
2012-08-18 11:03:30 +06:00
parent 9177257952
commit 7175860ae0
23 changed files with 476 additions and 499 deletions

View File

@@ -18,6 +18,48 @@ namespace Umbraco.Core
///</summary>
public static class StringExtensions
{
//this is from SqlMetal and just makes it a bit of fun to allow pluralisation
public static string MakePluralName(this string name)
{
if ((name.EndsWith("x", StringComparison.OrdinalIgnoreCase) || name.EndsWith("ch", StringComparison.OrdinalIgnoreCase)) || (name.EndsWith("ss", StringComparison.OrdinalIgnoreCase) || name.EndsWith("sh", StringComparison.OrdinalIgnoreCase)))
{
name = name + "es";
return name;
}
if ((name.EndsWith("y", StringComparison.OrdinalIgnoreCase) && (name.Length > 1)) && !IsVowel(name[name.Length - 2]))
{
name = name.Remove(name.Length - 1, 1);
name = name + "ies";
return name;
}
if (!name.EndsWith("s", StringComparison.OrdinalIgnoreCase))
{
name = name + "s";
}
return name;
}
public static bool IsVowel(this char c)
{
switch (c)
{
case 'O':
case 'U':
case 'Y':
case 'A':
case 'E':
case 'I':
case 'o':
case 'u':
case 'y':
case 'a':
case 'e':
case 'i':
return true;
}
return false;
}
/// <summary>
/// Trims the specified value from a string; accepts a string input whereas the in-built implementation only accepts char or char[].
/// </summary>