Tuesday, June 18, 2013

Suppose you want to override some behavior in a NopCommerce service via a plugin. You would start by subclassing the service that has the behavior you want to override. But what if your new code requires access to something that the existing service doesn’t know about?

The answer turns out to be pretty simple: just add it to your constructor, and the dependency resolver will figure it out for you. (You don’t need to worry about it.)

Here’s an example. I want to override the PictureService. So I started with this:

The solution turned out to be pretty obvious, and easy: include the powershell cookbook. For some reason I assumed it came in as part of the windows cookbook, but no. So just include it in your metadata.rb file like so: