private static IEnumerable <string> SeperateForReadability(this string value, ReadablilityCondition conditions) { char[] valueContent = value.ToCharArray(); List <List <char> > vals = new List <List <char> >(); for (int i = 0; i < valueContent.Length; i++) { if (i == 0 || (valueContent.IsUpper(i) && (valueContent.PreviousIsLower(i) || (valueContent.PreviousIsDigit(i) && conditions.HasFlag(ReadablilityCondition.ByDigit)) || valueContent.PreviousIsUnderscore(i) || valueContent.NextIsLower(i))) || (conditions.HasFlag(ReadablilityCondition.ByDigit) && valueContent.IsDigit(i) && !valueContent.PreviousIsDigit(i)) || (conditions.HasFlag(ReadablilityCondition.ByUnderscore) && valueContent.IsUnderscore(i))) { vals.Add(new List <char>()); } if (!valueContent.IsUnderscore(i)) { vals[vals.Count - 1].Add(valueContent[i]); } } foreach (List <char> i in vals) { yield return(new string(i.ToArray())); } }
private static bool CanMakeReadable(this ReadablilityCondition conditions, string value) { if (conditions.HasFlag(ReadablilityCondition.StopIfAnyWhitespace) && value.Contains(WhiteSpace)) { return(false); } return(true); }
private static bool Capitalize(this ReadablilityCondition conditions) { return(conditions.HasFlag(ReadablilityCondition.CapitalizeFirstCharacter)); }
private static bool TrimEndWhitespace(this ReadablilityCondition conditions) { return(conditions.HasFlag(ReadablilityCondition.TrimTrailingWhiteSpace)); }
private static bool TrimStartWhitespace(this ReadablilityCondition conditions) { return(conditions.HasFlag(ReadablilityCondition.TrimLeadingWhiteSpace)); }
private static IEnumerable<string> SeperateForReadability(this string value, ReadablilityCondition conditions) { char[] valueContent = value.ToCharArray(); List<List<char>> vals = new List<List<char>>(); for (int i = 0; i < valueContent.Length; i++) { if (i == 0 || (valueContent.IsUpper(i) && (valueContent.PreviousIsLower(i) || (valueContent.PreviousIsDigit(i) && conditions.HasFlag(ReadablilityCondition.ByDigit)) || valueContent.PreviousIsUnderscore(i) || valueContent.NextIsLower(i))) || (conditions.HasFlag(ReadablilityCondition.ByDigit) && valueContent.IsDigit(i) && !valueContent.PreviousIsDigit(i)) || (conditions.HasFlag(ReadablilityCondition.ByUnderscore) && valueContent.IsUnderscore(i))) vals.Add(new List<char>()); if (!valueContent.IsUnderscore(i)) vals[vals.Count - 1].Add(valueContent[i]); } foreach (List<char> i in vals) yield return new string(i.ToArray()); }