How does the "route" work?

Jan 22, 2011 at 1:20 PM

Thanks to sebastienros, I know where the default page is, , and I continued digging into it, until I find these codes:

namespace Orchard.Core.HomePage {
    public class Routes : IRouteProvider {
        public void GetRoutes(ICollection<RouteDescriptor> routes) {
            foreach (var routeDescriptor in GetRoutes())
                routes.Add(routeDescriptor);
        }
    }

What confused me is that I'd never found which method call it. I've tried by the following two approaches:
1. "Find All Refrence(Ctrl+F12)".
2. set the breakpoint.

Who can do me a favor and tell me what happened? Why no method call it?

Coordinator
Jan 23, 2011 at 5:34 AM

That's because we never ever go through the concrete implementation but always through the interface. So you need to go to the interface and find all references to the method on there.

Jan 23, 2011 at 9:12 AM

Thank you. But are you sure?

1. I’ve tried to find the references of its interface but still failed.

2. I think whatever, the breakpoint should be hit, right?

Coordinator
Jan 23, 2011 at 9:17 AM

Well, I can find plenty of references to the interface. I don't know what to say... As for the breakpoint, make sure to do that very early after recycling the web server: there may some caching going on.

Jan 23, 2011 at 11:58 AM

It’s so kind of you to give me a reply.

Thanks to your good advice, now I think probably there is confusion. Because there are two methods in IrouteProvider():

1. IEnumerable<RouteDescriptor> GetRoutes();

2. void GetRoutes(ICollection<RouteDescriptor> routes);

I find where the second one is invoked and its breakpoint here being hit. But thing doesn’t change for the first one.

Coordinator
Jan 24, 2011 at 6:59 PM

The way I understand it both methods should do the same thing anyway.