Esempio n. 1
0
            /// <summary>
            /// Extract the first character with optional upper or lower case
            /// </summary>
            /// <param name="from">String contents</param>
            /// <returns>Character (may be upper or lower case)</returns>
            public override object StringToField(string from)
            {
                if (string.IsNullOrEmpty(from))
                {
                    return(Char.MinValue);
                }

                try {
                    switch (mFormat)
                    {
                    case CharFormat.NoChange:
                        return(from[0]);

                    case CharFormat.Lower:
                        return(char.ToLower(from[0]));

                    case CharFormat.Upper:
                        return(char.ToUpper(from[0]));

                    default:
                        throw new ConvertException(from,
                                                   typeof(Char),
                                                   "Unknown char convert flag " + mFormat.ToString());
                    }
                }
                catch {
                    throw new ConvertException(from, typeof(Char), "Upper or lower case of input string failed");
                }
            }