TypeConverter problems.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter Morris

    #1

    TypeConverter problems.

    Hi all

    I created Collection + CollectionItem classes and a TypeConverter in order
    to persist the items in the collection. I then added descendants of these
    classes (ImageCollectio n, ImageItem).

    The persistence etc works fine until I add a property to the descended
    class, and then the created items do not appear in the collection editor
    list. Anyone have any ideas?


    internal class CollectionItemC onverter: TypeConverter
    {
    public override Boolean CanConvertTo(IT ypeDescriptorCo ntext context, Type
    destinationType )
    {
    if (destinationTyp e == typeof(Instance Descriptor))
    return true;
    return base.CanConvert To(context, destinationType );
    }

    public override object ConvertTo(IType DescriptorConte xt context,
    System.Globaliz ation.CultureIn fo culture, object value, Type
    destinationType )
    {
    if (destinationTyp e == typeof(Instance Descriptor))
    {
    System.Reflecti on.ConstructorI nfo ci =
    value.GetType() .GetConstructor (System.Type.Em ptyTypes);
    return new InstanceDescrip tor(ci, null, false);
    }
    return base.ConvertTo( context, culture, value, destinationType );
    }
    }



    --
    Pete
    =============
    Read or write technical articles


    Audio compression components, FastStrings library, DIB controls


    -There are 10 types of people in the world, those who understand binary, and
    those who don't



Working...