//http://validationframework.codeplex.com/
//License: Microsoft Permissive License (Ms-PL) v1.1
using System;
using System.Globalization;
using System.IO;
using System.Text;
using System.Xml;
namespace ValidationFramework.Extensions
{
/// <summary>
/// String helper methods
/// </summary>
public static class StringExtensions
{ /// <summary>
/// Splits string name into a readable string based on camel casing.
/// </summary>
/// <param name="value">The string to split.</param>
/// <returns>A modified <see cref="string"/> with spaces inserted in front of every, excluding the first, upper-cased character.</returns>
/// <exception cref="ArgumentNullException"><paramref name="value"/> is a null reference.</exception>
public static string ToCamelTokenized(this string value)
{
string space = " ";
if (value.Length ==0)
{
return value;
}
var stringBuilder = new StringBuilder(value.Length);
stringBuilder.Append(value[0]);
for (var index = 1; index < value.Length; index++)
{
var c = value[index];
if (Char.IsUpper(c))
{
stringBuilder.Append(space);
}
stringBuilder.Append(c);
}
return stringBuilder.ToString();
}
}
}
|