Accepted answer

unfortunatly i'm not aware of any other way (i also had to write such code more than once).

the one thing you can do is to make the where in the first method a bit nicer:

private list<type> getlistofgenericserializers()
  type interfacegenrictype = typeof(iserializedeserialize<>);

  var serializers =
    from assembly in appdomain.currentdomain.getassemblies()
    from generictype in assembly.gettypes()
    from interfacetype in generictype.getinterfaces()
    where generictype.isgenerictypedefinition &&
          interfacetype.isgeneric &&
          interfacetype.getgenerictypedefinition() == interfacegenerictype
    select generictype;

  return serializers.tolist();

Related Query

More Query from same tag