This project is read-only.

How to implement Custom IModelBinder within Orchard

Topics: Core, Writing modules
Jul 16, 2013 at 8:55 PM
Hi everybody.

I need to implement my custom model binder class.
Could somebody explain how can I do it so that orchard can register it and use it for my type.

Jul 18, 2013 at 8:36 PM
Ok, I have found it out.

To create custom model binder you need:
  1. Implement IModelBinder
  2. Implement IModelBinderProvider
    public class MyModelBinderProvider : IModelBinderProvider
        public IEnumerable<ModelBinderDescriptor> GetModelBinders()
            return new List<ModelBinderDescriptor>() { new ModelBinderDescriptor() { Type = (typeof(MyViewModel)), ModelBinder = new MyViewModelBinder() } };