Exemplo n.º 1
0
 public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
 {
     if (destinationType == typeof(string))
     {
         ToolSettings settings = value as ToolSettings;
         return(string.Format("{0},{1},{2}", settings.Downloaded.ToString(), settings.Enabled.ToString(), settings.LatestVersion));
     }
     return(base.ConvertTo(context, culture, value, destinationType));
 }
Exemplo n.º 2
0
 public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
 {
     if (value is string)
     {
         string[]     parts    = ((string)value).Split(new char[] { ',' });
         ToolSettings settings = new ToolSettings();
         if (parts[0] != null)
         {
             settings.Downloaded = Convert.ToBoolean(parts[0]);
         }
         if (parts[1] != null)
         {
             settings.Enabled = Convert.ToBoolean(parts[1]);
         }
         if (parts[2] != null)
         {
             settings.LatestVersion = parts[2];
         }
         return(settings);
     }
     return(base.ConvertFrom(context, culture, value));
 }