FubuRegistry
From FubuMVC Wiki
Contents |
Introduction
The key to configuring FubuMVC is the FubuRegistry. Create a class that derives from FubuMVC.Core.FubuRegistry, and configure it by calling methods in the constructor. This page describes the different options that are available.
The FubuRegistry DSL is still under construction. We will attempt to keep this page up to date, but there is a good chance that some of the properties/methods mentioned on this page may have changed.
Actions
The first step toward configuring FubuMVC is telling it how to wire up the Actions in your application. This process consists of:
- Action Discovery Identify methods that serve as Actions
- Route Generation Construct routes (URLs) for each Action
- Output Determination Determine the output mechanism (render a view, JSON, XML, etc) for each Action
- View Attachment Determine the View to associate with each Action (if any)
URL Lookup
UrlRegistry (TODO)
Model Binding
Models (TODO)
Add Behaviors
- ApplyConvention<TConvention>() (TODO)
- Policies (TODO)
Other
- IncludeDiagnostics (TODO)
- Import (TODO)
- Services (TODO)
- HomeIs (TODO)
Example
public class HelloWorldFubuRegistry : FubuRegistry
{
public HelloWorldFubuRegistry()
{
IncludeDiagnostics(true);
Applies.ToThisAssembly();
Actions
.IncludeTypesNamed(x => x.EndsWith("Controller"));
Routes
.IgnoreControllerNamespaceEntirely()
.ConstrainToHttpMethod(action => action.Method.Name.EndsWith("Command"), "POST")
.ConstrainToHttpMethod(action => action.Method.Name.StartsWith("Query"), "GET");
Views
.TryToAttach(x=>
{
x.to_spark_view_by_action_namespace_and_name(GetType().Namespace);
x.by_ViewModel_and_Namespace_and_MethodName();
x.by_ViewModel_and_Namespace();
x.by_ViewModel();
});
HomeIs<HomeInputModel>();
}
}