Call plugin Method

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
Hi there.

How do I call another plugin's method without having to add it as reference in my plugin's project?

I need the data from method return, so publish an event is out of question I believe.

How are you doing it under nop architecture ?

Thanks!
7 years ago
Dependency injection is used throughout the application to decouple classes from each other.
good for testing and upgrading classes without breaking interfaces, or to inject your own class that implements a particular interface, by example IExternalAuthenticationMethod.

https://en.wikipedia.org/wiki/Dependency_injection
7 years ago
Possible ways:

expose a referenced type (class) without need for additional reference

C# - Execute code from a .NET DLL (Class Library) without referencing it?
7 years ago
iob2000 wrote:
How do I call another plugin's method without having to add it as reference in my plugin's project?

How are you doing it under nop architecture ?

You can see how nop does it using the PluginFinder class by looking at something like the ShippingService class which uses the LoadActiveShippingRateComputationMethods function to get the active shipping rate computation method plugins used to fetch the shipping rates in the checkout.

That then calls the LoadAllShippingRateComputationMethods function which uses the PluginFinder class to load the actual plugin instances.

It then iterates through the loaded ShippingRateComputationMethods and calls the GetShippingOptions function from each plugin. This only works because every ShippingRateComputationMethod plugin implements the IShippingRateComputationMethod interface which defines a common contract for that type of plugin. Both the plugin and the nop website will therefore have a reference to the Nop.Services assembly where the IShippingRateComputationMethod interface is defined.

Whether that's applicable to your situation where you have 2 different plugins that need to share functionality really depends on the situation and what you're trying to achieve. Some plugin vendors have gone the route of having a core plugin which is required to be installed for any of their other plugins to function. That way you can just define the shared classes and functionality in the core plugin and reference it in each of the other plugins which keeps thing simpler and prevents you having to duplicate code across plugins.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.