I want to use AttributeRouting with Orchard CMS. To do so I need to implement an IRouteProvider
with a method that returns an list of Orchard RouteDescriptor
s.
I need a way to get the routes list so I can do something like this:
public IEnumerable<RouteDescriptor> GetRoutes()
{
return _routes ?? (_routes = MvcRouting.GetRoutes(GetType().Assembly).Select(route => new RouteDescriptor
{
...
}).ToArray());
}
This method is from MvcRouting but I want to use the more feature rich AttributeRouting but cannot find a way to scan current assembly for routing attributes. Need a way for AttributeRouting to return the list of routes that I can project into a list of RouteDescriptor
s but not actually registering them, leaving that to Orchard.
public class RouteDescriptor {
public string Name { get; set; }
public int Priority { get; set; }
public System.Web.Routing.RouteBase Route { get; set; }
public System.Web.SessionState.SessionStateBehavior SessionState { get; set; }
}
If I wanted to register the routes directly (in a non-Orchard project) I would use the following AttributeRouting extension methods:
routesCollection.MapAttributeRoutes(config =>
{
config.AddRoutesFromAssembly(Assembly.GetExecutingAssembly());
}
But this won't place nice with other Orchard modules. So need to take the approach above.
Any way you can think of?