how plugin routes are discovered and registered

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
i have read this http://alexwolfthoughts.com/understanding-routing-with-nopcommerce-plugins/

but i still have question about this

1   Application_Start() is the first step ,there is a line: RegisterRoutes(RouteTable.Routes);
2   in this method     public static void RegisterRoutes(RouteCollection routes)
            var routePublisher = EngineContext.Current.Resolve<IRoutePublisher>();
            routePublisher.RegisterRoutes(routes);

    what is EngineContext.Current.Resolve<IRoutePublisher>();?  is there every plugin route class in it?

    in the first place ,is  RouteCollection routes a empty collection?

3  
var routeProviderTypes = typeFinder.FindClassesOfType<IRouteProvider>();
what did this line actually find?
4
in this method  protected virtual PluginDescriptor FindPlugin(Type providerType)

this line: foreach (var plugin in PluginManager.ReferencedPlugins)  
what is PluginManager.ReferencedPlugins ?

please help me understanding this process.....
7 years ago
Hi,

In order the plugin to register some routes it should have a class that implements the IRouteProvider interface.

The typeFinder.FindClassesOfType<IRouteProvider>() finds all the classes that implements the IRouteProvider interface. Then each of these classes registers its own routes using the RegisterRoutes method.

You can read more about plugin creating here. There is a section specifically for routes.

I hope this helped !

Regards,
Deni
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.