binary serialized? what problems have you got?
Perhaps you have problems with typeconverters, please elaborate more on your
problem so others can help you...

Signature
Joey Calisay
http://spaces.msn.com/members/joeycalisay/
> I want to edit a collection in the designer and it to be stored as well (not
> binary serialized with all its version problems i got)
> code should be generated with property init not with a huge constructor. any
> hints which interfaces how to implement and special stuff about the
> collection to use?
Daniel K. - 10 Mar 2005 10:05 GMT
When i used it i got problems in a derived form (occasionally) that
the type was not as expected, i think some build version difference.
Anyway generating code seems a better solution since you can read it
easily in opposite to binary serialized anything.
The thing is i have a class that now works that contains kind a name
value list. its a very simple collection derived by CollectionBase and
has items with a attribute
[TypeConverter(typeof(NameIDPairConverter))]. The collection propery
in the control is marked with
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)].
Works well and code is generated that creates initialization code with
the constructor only.
What i need more is that i want to initialize the items with its
properties and not a huge constructor and more important: i need named
objects in the collection that i can use in the code. I mean after
editing the collection i expect something in the code like:
--------------
MyItem item0 = new MyItem();
item0.Text = "asdf";
..
MyCollection = new Collection(new MyItem[] { item0, .... } );
--------------
the items are not components or controls that should be displayed on
the UI.
Would be nice to know how to create such thing or whether there is a
reference implementation. I took a look on some classes with Reflector
but they are too complex to find out what i need in an acceptable time
and seperate the code generation i want from the functionality of that
classes itself. :)
My current type converter ConvertTo looks like this:
public override object ConvertTo(ITypeDescriptorContext context,
CultureInfo culture, object value, Type destinationType)
{
if(destinationType == typeof(string))
{
NameIDPair item = (NameIDPair)value;
return item.Name + " (ID=" + item.ID + ")";
}
if(destinationType == typeof(InstanceDescriptor))
{
NameIDPair item = (NameIDPair)value;
ConstructorInfo ctor =
typeof(NameIDPair).GetConstructor(new Type[] {typeof(string),
typeof(string)});
return new InstanceDescriptor(ctor, new object[] { item.Name,
item.ID } );
}
return base.CanConvertTo (context, destinationType);
}
> binary serialized? what problems have you got?
>
[quoted text clipped - 8 lines]
> > hints which interfaces how to implement and special stuff about the
> > collection to use?