I’m loading custom user controls into my form using reflection.
I would like all my user controls to have a “Start” and “End” method so they should all be like:
public interface IStartEnd
{
void Start();
void End();
}
public class AnotherControl : UserControl, IStartEnd
{
public void Start()
{ }
public void End()
{ }
}
I would like an interface to load through reflection, but the following obviously wont work as an interface cannot inherit a class:
public interface IMyUserControls : UserControl, IInit, IDispose
{
}
You can enforce the constraint at runtime that the class implementing
IMyUserControls : IInit, IDisposealsois UserControl. It’s reasonable to assume that the developers providing custom controls for your app know the requirements for the controls, so I don’t see a problem with performing the check at runtime.