mardi 27 décembre 2016

How to invoke a class from referenced DLL dynamically in C#

I need your help guys.

I'm planning to create a proxy service API in Visual Studio (C#), where it has a generic handler that receives as a parameter a class name with other params. Let's say:

api.ashx?serviceName=GetClients&param=...

In my solution, I'm planning to have many class libraries, while each of them will represent a service i am going to provide in my API to my clients. I will reference all DLLS of the class libraries (Services that will return JSON) to the main project where the Generic Handler exists. For instance, If my handler received a request with a parameter value "serviceName=GetClients", I'll need to look for the referenced DLL called "GetClients" using reflection. Then i'll call a generic function inside this DLL, which will do some logic, and return a JSON back to the handler.

What kind of design pattern should I use for my problem? also, If you can refer me to websites that explains what i need to do, it'll be great.

THANKS!

Aucun commentaire:

Enregistrer un commentaire