How do I make the Lock MonoRail DataBinder / SmartDispatcherController bind to types that contain properties that are interfaces?

We use interfaces to represent entity classes in our domain model. We have concrete implementations of these solutions by virtue of using LinqToSql. We've added a factory method for each LinqToSql class that our service layer uses to instantiate a new object (note this is different from the Controller's DataBind attribute).

MonoRail default DataBinder implementation will ignore properties that are defined as interfaces.

Ideally, we don't want to instantiate our data-tier classes in MonoRail - the whole point of interfaces is to decouple these concerns.

Also, we really don't want to create another set of concrete classes unrelated to LinqToSql whose only job is to translate between layers.

This is the end of a long day indeed ; can someone please have mercy and point us to the parts of the IDataBinder that we should overload with our own implementations or hint at other approaches that we might try ?; -)

+1


source to share


2 answers


You should be looking at IParameterBinder. take a look at the post I wrote on this topic



+3


source


As Ken pointed out, your idea can be implemented with a custom IParameterBinder.

The solution would be to use IOC:

  • allow a specific instance of the form from it.
  • then use IDataBinder to bind the instance to the request parameters

Another will use IDictionaryAdapter:

  • create a dto proxy for your frontend
  • then use IDataBinder to bind the dto proxy instance to the request parameters


NB: the second option won't work if the interface is:

  • is not public (hum)
  • has methods
  • or events
  • or readonly properties
  • or setonly properties

Finally, I don't know what is the problem with the specific class in the controller signature.

I myself use a concrete form in controllers that implement an interface defined in application layer services, this allows me to have problems separated on both sides:

  • controller side is Http mapping and first level data validation of form / command
  • Application layer services are business validation and form / command processing
0


source







All Articles