lundi 21 décembre 2015

Best way to initialize unknown types with parameters?

I'm trying to genericize some of our code by being able to instantiate objects that inherit from a base class without knowing the types of those objects. So I want to just be able to drop a dll in a directory and be able to instantiate those objects.

I was looking into MEF, but I can't export the parameters because they're not defined in code (loaded from a database). So it doesn't look like MEF is the way to go.

Reflection works great, but that seems too fragile to rely on.

Is there something I'm missing that would allow me to do this with MEF, is there another framework that would allow me to do this better, or is reflection simply the answer here?





Aucun commentaire:

Enregistrer un commentaire