Dynamically parsing a string as the name of an object

1 week ago 7
ARTICLE AD BOX

I'm building the backend of an application. It is not intended to be directly exposed to the internet, instead relying on an Apache hosted frontend.

After testing for validity, in my Task HandleRequest(), I need to create an entry point for execution of the request. Ideally, I would create some form of class template(?) that I would inherit from - such as
public class DoStuffWithWebStuff : Page

but doing this properly is not something I yet fully understand. In particular, the conversion from a string to a class object, based on the URL passed to the application.

I have started with creating a RouteMaster that evaluates Routes, and tests an incoming request before parsing it. How do I process the conversion from a string to a class object, based on the URL passed to the application here? I could theoretically just... write out each instantiation, but I'd like to be able to do it on the fly - something like:

string executeRequest(string requestedClass, <taskDictionary>) { <requestedClass> <objectRef> = new <requestedClass>(); <objectRef>.EntryPoint(<taskDictionary); // do rest of return value stuff here }

Is this feasible, or am I approaching this from the wrong angle?

Read Entire Article