Define an interface for loading custom UserControls through reflection

I load custom controls into my form using reflection. I would like all my user controls to have a Start and End method, so that they all are:

public interface IStartEnd
{
    void Start();
    void End();
}

public class AnotherControl : UserControl, IStartEnd
{            
    public void Start()
    { }

    public void End()
    { }
}

I would like the interface to load via reflection, but the following obviously does not work as an interface, cannot inherit a class:

public interface IMyUserControls : UserControl, IInit, IDispose
{

}
+3
source share
3 answers

, , IMyUserControls : IInit, IDispose is UserControl. , , , , .

0

, . Assembly.CreateInstance, , Activator.CreateInstance, CLR , .

, Assembly.GetTypes() , . , - , .

+1

Source: https://habr.com/ru/post/1745981/


All Articles