I currently have a list containing Call's, which is the base class. If I want to add derived classes of Call to the list, I know to do the following.
public class CustomCollectionEditor : System.ComponentModel.Design.CollectionEditor
{
private Type[] types;
public CustomCollectionEditor(Type type)
: base(type)
{
types = new Type[] { typeof(Call), typeof(CappedCall) };
}
protected override Type[] CreateNewItemTypes()
{
return types;
}
}
public class DisplayList
{
public DisplayList() { }
[Editor(typeof(CustomCollectionEditor), typeof(UITypeEditor))]
[DataMember] public List<Call> ListCalls { get; set; }
}
My questions is there anyway of moving where you mark up the Type[] containing all possible types the list can contain? I thought of adding the following to my CustomCollectionEditor class, but this doesn't work.
public CustomCollectionEditor(Type type, List<Type> types_)
: base(type)
{
types = types_.ToArray();
}
It would be ideal if I could mark up which classes the CustomCollectionEditor needed to be aware of in the DisplayList class somehow.