Пример #1
0
        private static Func <string, string> CreateIndividualTransform(string parameter)
        {
            if (string.IsNullOrWhiteSpace(parameter))
            {
                return(null);
            }

            var    firstColonIndex = parameter.IndexOf(':');
            string possibleFunction;

            if (firstColonIndex == -1)
            {
                possibleFunction = parameter;
                parameter        = null;
            }
            else
            {
                possibleFunction = parameter.Substring(0, firstColonIndex);
                parameter        = parameter.Length > firstColonIndex + 1 ? parameter.Substring(firstColonIndex + 1) : null;
            }

            possibleFunction = possibleFunction.Trim();
            switch (possibleFunction.ToLowerInvariant())
            {
            case "ap":
                return(AddPrefixTransform.GetTransform(parameter));

            case "as":
                return(AddSuffixTransform.GetTransform(parameter));

            case "rp":
                return(RemovePrefixTransform.GetTransform(parameter));

            case "rs":
                return(RemoveSuffixTransform.GetTransform(parameter));

            case "t":
                return(ProcessHelper.GetTransformFuncFromValue(parameter));

            case "d":
                return(DefaultTransform.GetTransform(parameter));

            default:
                switch (possibleFunction)
                {
                case "tl":
                case "Tl":
                case "l":
                    return(ProcessHelper.GetTransformFuncFromTransform(Transform.FirstLower));

                case "tL":
                case "TL":
                case "L":
                    return(ProcessHelper.GetTransformFuncFromTransform(Transform.AllLower));

                case "tu":
                case "Tu":
                case "u":
                    return(ProcessHelper.GetTransformFuncFromTransform(Transform.FirstUpper));

                case "tU":
                case "TU":
                case "U":
                    return(ProcessHelper.GetTransformFuncFromTransform(Transform.AllUpper));
                }
                break;
            }
            return(null);
        }
Пример #2
0
 public string Transform(string value)
 {
     return(ProcessHelper.RemoveSuffix(value, _suffix));
 }