Tuesday 15 April 2014

inheritance - ASP.NET MVC ModelBinding Inherited Classes -


I have a question about modeling in ASP.NET MVC (I'm using MVC 2 2 Preview 2) Related to Heritage

Say I have the following interfaces / classes:

  Interface Ibbase class base: IBIS interface iCheld class child: base, Ichid  
< P> And I have a custom model binder besomodel builder.

The following tasks are correct:

  ModelBinders.Binders [typeof (hair)] = new besomodelbender (); Modalbinders.bunders [typef (icilied)] = new besodelbander ();  

The following do not work (if you force hair on one type of object):

  ModelBinders.Binders [typeof (base)] = new besodelbander ( ); Modalbinders.bunders [typef (ibiz)] = new besomodelbender ();  

Is there a way to keep model binders for a base class that will be applicable in all heritage classes? I really do not want to input something for every potential heritage class.

In addition, if possible, is there a way to override the Modelbender for a specific heritage class? Say I got this job but I needed a specific modular for Child 2.

Thanks in advance.

I have taken a simple route, I just used all the derivative classes dynamically at the startup using reflection I register. Perhaps this is not a clean solution, but there are some lines in the initial code that just works; -)

But if you really want to mess with those who make model (you're yes


No comments:

Post a Comment