示例#1
0
        public override object Convert(object source, Type sourceType, Type targetType)
        {
            string asString = source as string;

            if (string.IsNullOrEmpty(asString))
            {
                return(null);
            }

            targetType = ConversionUtils.GetNullableElementType(targetType);
            return(Enum.Parse(targetType, asString.Trim(), true));
        }
        public override bool Matches(Type sourceType, Type targetType)
        {
            var targetCheck = ConversionUtils.GetNullableElementType(targetType);

            return(sourceType == typeof(string) && targetCheck == typeof(char));
        }