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; | |
} | |
} |
Yes, it's all one assembly...but isn't it the behaviour you expect? The action I use as Home does not enter the UrlPolicy. This also happens in the HelloSpark app in fubu, I checked via /_fubu/routes
The action matching should have hit the HomeController and added the two actions to the BehaviorGraph just fine. Yes, the CharmSimUrlPolicy should never hit the HomeController.Start method because it already has a Route (HomeIs adds a route with "" as the pattern). You should see the SomethingElse() in your _fubu/chains view
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
Is your HomeController in the same assembly as your CharmSimRegistry?