CSharpFeeds - All your C# feeds in one place.

Sponsors

Sunday, May 02, 2010

Magellan Route Registration

by Paul Stovell via Paul Stovell on 5/2/2010 12:27:40 PM

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 :)

email it!bookmark it!digg it!

Original Post: Magellan Route Registration

Subscribe

New Feed

Product Spotlight

Recently Updated Sources

Legal Note

The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.

Advertise with us