简体   繁体   中英

Is there a way to consume events just by copying a dll into bin?

I have a asp.net web application and it has few application events; say for example - Create User. One of my clients want a notification when a new user is created. So I have a dll specific to that client where I can put the logic for sending notification by registering to the application event onCreateUser.

Now I would like to know is there a better and generic way so that by just replacing this dll, for a different client, I can do something else instead of sending notification. Or by simply removing the dll I can turn this behavior off.

Edit: I know it is possible to do this by dynamically loading dlls applying reflection using Attributes just like PreApplicationStartMethodAttribute or using Interface and so on. But wanted to make sure I am not reinventing the wheel.

I am assuming you are trying/have implemented the observer pattern for OOP? Because that is the pattern I would build my code from.

So pseudo-code:

 notification method{User createdUser}
{
   bool shouldNotify = dataHandler.getUserNotificationValue(createdUser);
   if(shouldNotify )
   {
       notifier.SendNotification();
   }
}

This would remove the requirement to even have a DLL pr client, just a db/xml file/etc. with a list of relations between clients who requires a notification.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM