Magellan Route Registration
This week I have been working on a routing system for Magellan. The goal was to make it very similar to ASP.NET's style of routing:
Routes.Register("Default",
"{controller}/{action}/{id}", // Path specification
new { controller = "Home", action = "Index", id = "" }, // Defaults
new { id = "^[0-9]+$" } // Constraints
);
Unfortunately, I hadn't counted on Silverlight's security implementation. Since anonymous types are internal, I can't use reflection to pull apart the defaults and constraints the way ASP.NET MVC does.
Which of these syntaxes do you prefer?
Routes.Register("Default", "{controller}/{action}/{id}")
.Defaults(controller => "Home", action => "Index", id => "")
.Constraints(id => "^[0-9]+$");
Routes.Register("Default",
"{controller}/{action}/{id}",
new Defaults(controller => "Home", action => "Index", id => ""),
new Constraints(id => "^[0-9]+$")
);
Alternatively, please suggest a better alternative :)