I have a class:
public class Filter
{
public Filter (string name, string value)
{
Name = name;
Value = value;
}
public string Name {get; private set;}
public string Value {get; set;}
}
And a collection class:
public class FilterCollection : Collection<Filter>
{
// code elided
}
My component class:
public class MyComponent : Component
{
// ...
[Editor(typeof(FilterEditor), typeof(UITypeEditor))]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public FilterCollection Filters { get; set; }
// ...
}
The problem is that the collection is not serialized correctly by the designer.
I’m sure I’m missing something but I don’t know what.
ADDITIONAL INFO
What I would like the designer.cs file to have is something along the following:
myComponent.Filters.Add (new Filter ("some name", "some value"));
myComponent.Filters.Add (new Filter ("other name", "other value"));
Is this feasible?
Ok, problem solved.
I needed to use a TypeConverter for my Filter class:
The converter is then added to the Filter class like so:
The important thing to note here is the creation of an instance descriptor with the required parameters for the Filter constructor. Also, you need to set the last parameter (isComplete) of the InstanceDescriptor constructor to true.