mardi 11 décembre 2018

How to create instance from string and convert to interface type?

I have a string that is my service name. I want to create an instance from this string. my container is simple injector in this code. code is :

Type type = Type.GetType("IAppIssueDebitBatchService");
mycontainer.GetInstance<type>();

but I can't cast type to interface. because in mycontainer I need an interface like this :

mycontainer.GetInstance<IAppIssueDebitBatchService>();

how do that?

thanks.





Aucun commentaire:

Enregistrer un commentaire