This repository has been archived by the owner on Oct 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Custom view model binders
Alexanderius edited this page Jan 1, 2019
·
1 revision
To use custom model view binder you should register it using HttpModelHandler.RegisterModelBinder
, it will be added to binders pipeline.
public class Startup
{
public void Configuration(IAppBuilder app)
{
...
HttpModelHandler.RegisterModelBinder<MyModelBinder>();
app.UseSimplifyWeb();
}
}
Binder should be deriver from IModelBinder
interface.
public class MyModelBinder : IModelBinder
{
public void Bind<T>(ModelBinderEventArgs<T> args)
{
// deserialization logic
}
}
If you just want to use your binder without default binders, then you should clear binders list first.
public class Startup
{
public void Configuration(IAppBuilder app)
{
...
HttpModelHandler.ModelBindersTypes.Clear();
HttpModelHandler.RegisterModelBinder<MyModelBinder>();
app.UseSimplifyWeb();
}
}
One example of custom model binder is JsonModelBinder.
- Getting Started
- Main Simplify.Web principles
- Simplify.Web controllers
- Simplify.Web views
- Simplify.Web templates
- Simplify.Web configuration
- Templates variables
- Static content
- Template factory
- Data collector
- String table
- File reader
- Web context
- Environment
- Language manager
- Redirector
- HTML
- Dependency Injection
- Custom Simplify.Web bootstrapper
- Custom controller response
- Mocking controllers and views
- Authentication
- Custom view model binders
- Custom view model validators