manual merge pass #2

This commit is contained in:
Shannon
2018-10-02 12:57:19 +02:00
parent edc9744397
commit 0c5cf5256b
7 changed files with 84 additions and 41 deletions

View File

@@ -1384,6 +1384,30 @@ namespace Umbraco.Core
return idCheckList.Contains(value);
}
/// <summary>
/// Converts a file name to a friendly name for a content item
/// </summary>
/// <param name="fileName"></param>
/// <returns></returns>
public static string ToFriendlyName(this string fileName)
{
// strip the file extension
fileName = fileName.StripFileExtension();
// underscores and dashes to spaces
fileName = fileName.ReplaceMany(new[] { '_', '-' }, ' ');
// any other conversions ?
// Pascalcase (to be done last)
fileName = CultureInfo.InvariantCulture.TextInfo.ToTitleCase(fileName);
// Replace multiple consecutive spaces with a single space
fileName = string.Join(" ", fileName.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries));
return fileName;
}
// From: http://stackoverflow.com/a/961504/5018
// filters control characters but allows only properly-formed surrogate sequences
private static readonly Lazy<Regex> InvalidXmlChars = new Lazy<Regex>(() =>