public override object Convert(Type desiredType, Type inputType, object input, out bool conversionSucceeded)
        {
            conversionSucceeded = true;

            String value = ConverterUtil.NormalizeInput(input);

            if (IsBool(desiredType))
            {
                return(SpecialBoolConversion(value, input, ref conversionSucceeded));
            }
            else if (input == null)
            {
                conversionSucceeded = false;
                return(null);
            }
            else if (value == String.Empty)
            {
                conversionSucceeded = true;
                return(null);
            }
            else
            {
                return(System.Convert.ChangeType(input, desiredType));
            }
        }
        /// <summary>
        /// Converts the specified desired type.
        /// </summary>
        /// <param name="desiredType">Type of the desired.</param>
        /// <param name="inputType">Type of the input.</param>
        /// <param name="input">The input.</param>
        /// <param name="conversionSucceeded">if set to <c>true</c> [conversion succeeded].</param>
        /// <returns><see cref="DateTime"/> if conversion successful, <c>null</c> otherwise.</returns>
        public override object Convert(Type desiredType, Type inputType, object input, out bool conversionSucceeded)
        {
            conversionSucceeded = input != null;

            if (input == null)
            {
                return(null);
            }

            string value = ConverterUtil.NormalizeInput(input);

            if (value == String.Empty)
            {
                conversionSucceeded = false;

                return(null);
            }

            return(DateTime.Parse(value));
        }
Beispiel #3
0
        public override object Convert(Type desiredType, Type inputType, object input, out bool conversionSucceeded)
        {
            conversionSucceeded = input != null;

            if (input == null)
            {
                return(null);
            }

            String value = ConverterUtil.NormalizeInput(input);

            if (value == String.Empty)
            {
                conversionSucceeded = true;
                return(null);
            }
            else
            {
                return(new Guid(value));
            }
        }