示例#1
0
        /// <summary>
        /// Converts a string to the corresponding value type.
        /// </summary>
        /// <param name="context">Type descriptor context.</param>
        /// <param name="culture">Globalization info.</param>
        /// <param name="value">The value being converted.</param>
        /// <returns>The converted value.</returns>
        public override Object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
        {
            foreach (DataTypeBase type in DataTypeBase.GetScannableDataTypes())
            {
                if (type == (DataTypeBase)null || !(value is String))
                {
                    break;
                }

                if (Conversions.DataTypeToName(type) == value as String)
                {
                    return(type);
                }
            }

            return(base.ConvertFrom(context, culture, value));
        }
示例#2
0
 /// <summary>
 /// Gets the standard collection of values to display in a drop down.
 /// </summary>
 /// <param name="context">Type descriptor context.</param>
 /// <returns>The standard collection of values.</returns>
 public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
 {
     return(new StandardValuesCollection(DataTypeBase.GetScannableDataTypes()
                                         .Select(dataType => Conversions.DataTypeToName(dataType))
                                         .ToList()));
 }