Beispiel #1
0
        public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
        {
            string s = value as string;

            if (s != null)
            {
                DrawingLayerHeaderList hl = new DrawingLayerHeaderList();
                string[] ss = s.Split('|');
                if (ss.Length > 0)
                {
                    TypeConverterLayerHead th = new TypeConverterLayerHead();
                    for (int i = 0; i < ss.Length; i++)
                    {
                        hl.Add((DrawingLayerHeader)th.ConvertFromInvariantString(ss[i]));
                    }
                    return(hl);
                }
            }
            return(base.ConvertFrom(context, culture, value));
        }
Beispiel #2
0
 public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
 {
     if (typeof(string).Equals(destinationType))
     {
         DrawingLayerHeaderList k = value as DrawingLayerHeaderList;
         if (k != null)
         {
             TypeConverterLayerHead th = new TypeConverterLayerHead();
             StringBuilder          sb = new StringBuilder();
             for (int i = 0; i < k.Count; i++)
             {
                 if (i > 0)
                 {
                     sb.Append("|");
                 }
                 sb.Append(th.ConvertToInvariantString(k[i]));
             }
             return(sb.ToString());
         }
     }
     return(base.ConvertTo(context, culture, value, destinationType));
 }