So i try to create a PluginService which loads assemblys from a folder and checks if it implements a certain interface. I work with the Interface
public interface IService
{
void Start();
void Stop();
void Restart();
}
And the Class
public class Service : IService
{
public Service()
{
}
public void Restart()
{
}
public void Start()
{
}
public void Stop()
{
}
}
And i found this Question from pogorman which helped me a lot.
EDIT:
Sorry for the confussion i mean this code snippet not the DoesTypeImplementInterface
currentAssembly.GetTypes()
.Where(t => t != typeof(T) && typeof(T).IsAssignableFrom(t))
.ToList()
.ForEach(x => implementors.Add((T)Activator.CreateInstance(x)));