Look how we can configure the fubu :
This file contains hidden or 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 ConfigureFubuMVC() | |
{ | |
Applies.ToThisAssembly(); | |
Applies.ToAssembly("MyProject.Data"); | |
Actions | |
.IncludeTypesNamed(x => x.EndsWith("Action")); | |
Routes | |
.IgnoreControllerNamespaceEntirely() | |
.IgnoreClassSuffix("Action") | |
.IgnoreMethodsNamed("Execute") | |
.IgnoreMethodSuffix("Command") | |
.IgnoreMethodSuffix("Query") | |
.ConstrainToHttpMethod(action => action.Method.Name.EndsWith("Command"), "POST") | |
.ConstrainToHttpMethod(action => action.Method.Name.StartsWith("Query"), "GET"); | |
Views.TryToAttachWithDefaultConventions(); | |
} |
In the first lines, I tell the framework that configuration only applies to MyProject.dll and MyProject.Data.dll.
Then all classes that ends with action are my controllers. (with mvc literature).
Then ignore all namespaces for action classes also ignore certain suffixes, for example, if an action class is deep in the project like (MyProject.UI.Actions.Exchange.AddExchangeAction), for routing just call AddExchange.
All Views that are using the model on their back, should have the same name as their models.
This stuff is set when the application starts and no needs to reconfigure for each situation.
No comments:
Post a Comment