예제 #1
0
        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()));
            }
        }
예제 #2
0
        private static bool CanMakeReadable(this ReadablilityCondition conditions, string value)
        {
            if (conditions.HasFlag(ReadablilityCondition.StopIfAnyWhitespace) &&
                value.Contains(WhiteSpace))
            {
                return(false);
            }

            return(true);
        }
예제 #3
0
 private static bool Capitalize(this ReadablilityCondition conditions)
 {
     return(conditions.HasFlag(ReadablilityCondition.CapitalizeFirstCharacter));
 }
예제 #4
0
 private static bool TrimEndWhitespace(this ReadablilityCondition conditions)
 {
     return(conditions.HasFlag(ReadablilityCondition.TrimTrailingWhiteSpace));
 }
예제 #5
0
 private static bool TrimStartWhitespace(this ReadablilityCondition conditions)
 {
     return(conditions.HasFlag(ReadablilityCondition.TrimLeadingWhiteSpace));
 }
예제 #6
0
        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());
        }