'How to provide some available values when using interface as type for form custom property?

If possible, I need to provide available implementations of an interface as values for a property of a custom form.

Below is a simple code example:

public interface IDoThings {
    void DoInitialThing();
}

public class StandardDoer : IDoThings {
    public void DoInitialThing() {
        throw new Exception("I did something!");
    }
}

public class NoDoer : IDoThings {
    public void DoInitialThing() {
        throw new Exception("I did nothing!");
    }
}

public class AllDoer : IDoThings {
    public void DoInitialThing() {
        throw new Exception("I did everything!");
    }
}

public partial class CustomForm : Form {
    [Browsable(true)]
    [Category("Behavior")]
    [DefaultValue(null)]
    [Description("The IDoThings override.")]
    public IDoThings Doer { get; set; }
    protected IDoThings _doerDefault = new StandardDoer();

    public CustomForm() {
        InitializeComponent();
        (Doer ?? _doerDefault).DoInitialThing();
    }
}

public partial class UsingCustomForm : CustomForm {
    public UsingCustomForm() {
        InitializeComponent();
    }
}

Let's say we use reflection to gather all the types implementing "IDoThings" in a container (array, list, dictionary, ...) and let's say we are able to instantiate them using their name once one of them is chosen.

Question: Is it possible to make the "IDoThings" implementations known for the "UsingCustomForm"'s "Doer" property on design time in order to chose one (or none)?

I wouldn't want you to bother writing code. If the above is possible, please point me in the right direction. If not, maybe you have another approach? In any case I will try the recommendations and follow up if necessary.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source