Exemple #1
0
 /// <summary>
 /// Converts the given value object to the specified type, using the specified context and culture information.
 /// </summary>
 /// <param name="context">An System.ComponentModel.ITypeDescriptorContext that provides a format context.</param>
 /// <param name="culture">A System.Globalization.CultureInfo. If null is passed, the current culture is assumed.</param>
 /// <param name="value">The System.Object to convert.</param>
 /// <param name="destinationType">The System.Type to convert the value parameter to.</param>
 /// <returns>An System.Object that represents the converted value.</returns>
 public override object ConvertTo(ComponentModel.ITypeDescriptorContext context, Globalization.CultureInfo culture, object value, Type destinationType)
 {
     if (destinationType == typeof(string))
     {
         return((bool)value ? "Male" : "Female");
     }
     return(base.ConvertTo(context, culture, value, destinationType));
 }
Exemple #2
0
        public override bool CanConvertFrom(ComponentModel.ITypeDescriptorContext context, Type sourceType)
        {
            if (sourceType == typeof(string))
            {
                return(true);
            }

            return(base.CanConvertFrom(context, sourceType));
        }
Exemple #3
0
        public override bool IsValid(ComponentModel.ITypeDescriptorContext context, object value)
        {
            string valstr = value as string;

            if (valstr != null)
            {
                if (valstr.StartsWith("data:"))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #4
0
 public override object ConvertFrom(ComponentModel.ITypeDescriptorContext context, Globalization.CultureInfo culture, object value)
 {
     if (value is string)
     {
         string valstr = value as string;
         if (string.IsNullOrEmpty(valstr) == false && valstr.StartsWith("data:"))
         {
             return(DataUri.Parse(valstr));
         }
         else
         {
             return(null);
         }
     }
     return(base.ConvertFrom(context, culture, value));
 }