Skip to content

Instantly share code, notes, and snippets.

@flq
Created May 6, 2011 13:28
Show Gist options
  • Save flq/958950 to your computer and use it in GitHub Desktop.
Save flq/958950 to your computer and use it in GitHub Desktop.
Current Fubu registry
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; }
}
}
public class CharmSimRegistry : FubuRegistry
{
public CharmSimRegistry()
{
IncludeDiagnostics(true);
Applies.ToThisAssembly();
Actions.IncludeClassesSuffixedWithController();
this.WithSparkDefaults();
Routes
.IgnoreControllerNamespaceEntirely()
.UrlPolicy<CharmSimUrlPolicy>()
.HomeIs<HelpController>(c => c.Start());
}
}
<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>
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;
}
}
@flq
Copy link
Author

flq commented May 6, 2011

That's settled then, thanks for your time...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment