Forum Programmation.c# Problème avec IsSubclassOf
je me lance dans le C#.
J'ai un programme qui doit charger des DLLs. Ces DLLs implémentent l'interface PluginInterface.
Programme principal:
foreach (Type type in assembly.GetTypes())
{
if (type.IsSubclassOf(typeof(PluginInterface)) || type.Equals(typeof(PluginInterface))
|| type == typeof(PluginInterface) || type.IsInstanceOfType(typeof(PluginInterface))) // && !type.IsAbstract) if PluginInterface is not an Interface
{
Console.WriteLine("and this is a plugin");
pluginList.Add((PluginInterface) Activator.CreateInstance(type));
}
else
Console.WriteLine("but this is NOT a plugin ({0}) ({1})", type, typeof(PluginInterface));
}
La DLL:
public class Plugin : PluginInterface
{
....
}
Et en (…)