Example #1
0
 public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
 {
     if (destinationType == typeof(string))
     {
         string     str = String.Empty;
         ReasonCode rc  = value as ReasonCode;
         if (rc != null)
         {
             str = string.Format("{0},{1}", rc.id, rc.description);
         }
         return(str);
     }
     else
     {
         return(base.ConvertTo(context, culture, value, destinationType));
     }
 }
Example #2
0
 public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
 {
     if (value.GetType() == typeof(string))
     {
         ReasonCode rc  = new ReasonCode();
         string     str = value as string;
         if (str != null)
         {
             str = str.Trim();
             string[] props = str.Split(new char[] { ',' }, StringSplitOptions.None);
             rc.id          = ushort.Parse(props[0]);
             rc.description = props[1];
         }
         return(rc);
     }
     else
     {
         return(base.ConvertFrom(context, culture, value));
     }
 }