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 :)
Hello, I'm Paul Stovell
I'm a Brisbane-based software developer, and founder of Octopus Deploy, a DevOps automation software company. This is my personal blog where I write about my journey with Octopus and software development.
I write new blog posts about once a month. Subscribe and I'll send you an email when I publish something new.
Subscribe
Comments