Created
May 6, 2011 13:28
-
-
Save flq/958950 to your computer and use it in GitHub Desktop.
Current Fubu registry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using FubuMVC.Core; | |
namespace CharmSim.Controllers | |
{ | |
public class HelpController | |
{ | |
public HelpViewModel Start() | |
{ | |
return new HelpViewModel { Title = "Hello from Controller! " }; | |
} | |
public HelpViewModel SomethingElse(HelpInputModel input) | |
{ | |
return new HelpViewModel { Title = "Hello from Controller! " + input.HelpId }; | |
} | |
} | |
public class HelpInputModel | |
{ | |
public HelpInputModel(string helpId) | |
{ | |
HelpId = helpId; | |
} | |
[RouteInput] | |
public string HelpId { get; set; } | |
} | |
public class HelpViewModel | |
{ | |
public string Title { get; set; } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CharmSimRegistry : FubuRegistry | |
{ | |
public CharmSimRegistry() | |
{ | |
IncludeDiagnostics(true); | |
Applies.ToThisAssembly(); | |
Actions.IncludeClassesSuffixedWithController(); | |
this.WithSparkDefaults(); | |
Routes | |
.IgnoreControllerNamespaceEntirely() | |
.UrlPolicy<CharmSimUrlPolicy>() | |
.HomeIs<HelpController>(c => c.Start()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<viewdata model="CharmSim.Controllers.HelpViewModel" /> | |
<content:title>Charms System simulator</content:title> | |
<content:header>Charms System simulator</content:header> | |
<h1>${Model.Title}</h1> | |
<a href="${this.Urls.UrlFor(new HelpInputModel("23"))}">bla</p> | |
<p>!{this.LinkTo(new HelpInputModel("fr")).Text("Go Here")}</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CharmSimUrlPolicy : IUrlPolicy | |
{ | |
public bool Matches(ActionCall call, IConfigurationObserver log) | |
{ | |
return call.HandlerType.Name.EndsWith("Controller"); | |
} | |
public IRouteDefinition Build(ActionCall call) | |
{ | |
var route = call.ToRouteDefinition(); | |
route.Append(call.HandlerType.Name.RemoveSuffix("Controller")); | |
route.Append(call.Method.Name); | |
return route; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That's settled then, thanks for your time...