私は現在、基本クラスである Call を含むリストを持っています。Call の派生クラスをリストに追加する場合は、次の手順を実行する必要があります。
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; }
}
私の質問は、リストに含めることができるすべての可能なタイプを含む Type[] をマークアップする場所に移動することですか? CustomCollectionEditor クラスに以下を追加することを考えましたが、うまくいきません。
public CustomCollectionEditor(Type type, List<Type> types_)
: base(type)
{
types = types_.ToArray();
}
CustomCollectionEditor がどのクラスを認識する必要があるかを DisplayList クラスで何らかの方法でマークアップできれば理想的です。