lundi 26 mars 2018

C# find all class implement interface without generic type

I have Interface with Generic Type

public interface IWork<T>
{
    void Work(MySession session, T json);
}

I am trying to find all Classes that implement the Interface with all generic types, when trying this code

var type = typeof(IWork<>);
var types = AppDomain.CurrentDomain.GetAssemblies()
            .SelectMany(s => s.GetTypes())
            .Where(p => type.IsAssignableFrom(p));

Its return the Interface it self.





Aucun commentaire:

Enregistrer un commentaire