logo
Welcome to our new AbleCommerce forums. As a guest, you may view the information here. To post to this forum, you must have a registered account with us, either as a new user evaluating AbleCommerce or an existing user of the application. For all questions related to the older version of Gold and earlier, please go to AbleCommerce Gold forum. Please use your AbleCommerce username and password to Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
sweeperqb  
#1 Posted : Monday, May 3, 2021 8:43:08 AM(UTC)
sweeperqb

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

Wanna join the discussion?! Login to your AbleCommerce Forums forum account. New Registrations are disabled.

shaharyartiwana25816656  
#2 Posted : Tuesday, May 4, 2021 1:51:48 AM(UTC)
shaharyar

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);


thanks 1 user thanked shaharyar for this useful post.
sweeperqb on 5/4/2021(UTC)
Users browsing this topic
Guest
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.