Rank: Advanced Member
Groups: Authorized User, Developers Joined: 5/30/2020(UTC) Posts: 125
Thanks: 14 times Was thanked: 3 time(s) in 3 post(s)
|
Was looking at the documentation for the AC Event System. Given the example, EventsManager.Instance.OrderPlaced += new OrderPlacedHandler(eventHandler.OrderPlaced), it appears this is a static implementation. I'm trying to keep everything I can in the plug-in so we're not modifying the core code. What is the preferred method for us to tie in our custom event handlers so they are only added once? The documentation says "hook these event handlers functions at application start". To me that implies customizing Application_Start() within Global.asax. That seems to defeat the purpose of a plug-in system. Is there a way to inject our event handlers via the plugin system that I'm overlooking? For instance, is there a RegisterEvents function, or something similar, that we can tie into that only fires once? Edited by user Monday, May 3, 2021 8:45:22 AM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Admin, Developers, Registered, HelpDesk, Authorized User Joined: 10/5/2018(UTC) Posts: 704
Thanks: 5 times Was thanked: 113 time(s) in 112 post(s)
|
Quote:The documentation says "hook these event handlers functions at application start". To me that implies customizing Application_Start() within Global.asax. That seems to defeat the purpose of a plug-in system. Is there a way to inject our event handlers via the plugin system that I'm overlooking? You can inject your event handlers in the RouteProvider class of the plugin. Following the documentation example: Open your plugin RouteProvider class and add the following code at the end of the RegiterRoutes function. Code:var eventHandler = new MyEventsHandler();
EventsManager.Instance.OrderPlaced += new OrderPlacedHandler(eventHandler.OrderPlaced);
EventsManager.Instance.OrderCancelled += new OrderCancelledHandler(eventHandler.OrderCancelled);
|
1 user thanked shaharyar for this useful post.
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The AbleCommerce Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close