Exemple #1
0
        internal static object DoConversionFrom(TypeConverter converter, object value)
        {
            object obj = value;

            try
            {
                if (converter != null)
                {
                    if (value != null)
                    {
                        if (converter.CanConvertFrom(value.GetType()))
                        {
                            obj = converter.ConvertFrom((ITypeDescriptorContext)null, CultureInfo.InvariantCulture, value);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (!TypeConverterHelper.ShouldEatException(ex))
                {
                    throw;
                }
            }
            return(obj);
        }
Exemple #2
0
        private static bool ShouldEatException(Exception e)
        {
            bool flag = false;

            if (e.InnerException != null)
            {
                flag = flag | TypeConverterHelper.ShouldEatException(e.InnerException);
            }
            return(flag | e is FormatException);
        }