Inheriting ModelBinderProvider

Topics: Core, Customizing Orchard, General, Troubleshooting
Apr 24 at 10:06 PM
Edited Apr 24 at 10:11 PM
Dear all!

For a ViewModel I have a similar structure like on StackOverflow:

Code in model:
public class AViewModel {

List<IFormSubmission> listOfSubmissions = new List<IFormSubmission>();

public interface IFormSubmission

public class Text: IFormSubmission

public class BetweenYears: IFormSubmission

public class Slider: IFormSubmission
These values, once posted, should be put in "listOfSubmissions" in the model.

I did not get very far with the hungarian hint, so I looked for a solution which would be mentioned in the post of an inheritance-aware ModelBinderProvider

I know that I would have to provide another way to distinguish which implementation of the interface should be taken if more than one interface is implementing it.

Can Orchard support this? Or is there a better solution?


May 10 at 10:44 AM
One simple way to select the desired implementation is to first resolve an IEnumerable<IFormSubmission> and then select the one you want.
Another way should be possible by registering the IFormSubmission interface and its implementations yourself by implementing Autofac's Module class (see for more information).