I’m building a website that will send an email notification when certain actions are completed. As of right now, I’ve got a generic notification function that is called in certain areas with parameters to reference a database record containing the message, etc.
I’d like to know if there is any way to make a trigger like this dynamic so adding/removing triggers in different areas of the website doesn’t require codebehind changes. I was thinking something with reflection and the namespace/function to call the trigger from loaded from the database, but I would imagine that would have a significant performance impact.
Reflection really does not have that big of a performance impact, especially when you factor in caching the function pointers after the first time you do a lookup.
This is a simple spike, may not compile or work, but should get you on the right path:
Parser is a MethodInfo object, and can be cached to be used later. Calling invoke is no worse performant than calling
DateTime.Parsedirectly. If I had to guess, the slowest call is to Type.GetType, even then though we are not talking about a lot of time, definitely on the ms scale.If you can give a little more information too, it’s possible someone can point you in a better direction even. Maybe a little DI or IoC information is pertinent.