The normal approach is using reflection to enumerate the available types and map them to the requested type. But instead of doing this manually, you should use a dependency container like Unity or MEF.
Where does the type string comes from in the first code snippet?
functions["PRODUCTS"](); // Executes ProductsList()
This has a very strong code smell. Using a discriminator is often a bad sign. Normally you can use inheritance. But for concrete advice you should show uas more of your code here.
No comments:
Post a Comment