Has ValueInjector support for inheritance mapping?

Jun 21, 2010 at 8:18 AM
I just found your ValueInjecter which looks promising, good job. I wonder if ValueInjector supports mapping for derived classes. E.g.: On the "Source" side, I have got the following two classes: class BaseClass{ // some properties.... } class DerivedClass : BaseClass { // some additional properties } on the destination side I have the corresponding target types: class DestinationBaseClass{ // some properties which are named differently } class DestinationDerivedClass : DestinationBaseClass { // some additonal properties which are named differently } How to configure the mapping from BaseClass to DestinationBaseClass and from DerivedClass to DestinationDerivedClass? Is ValueInjecter using the proper (=more specific) mapping strategy when given BaseClass which is DerivedClass during runtime? It had been awesome (and allowed for DRY mapping code) if one could define a mapping from BaseClass to DesintationBaseClass and a mapping DerivedClass to DestinationDerivedClass with only the properties which are specific for this inheritance level and ValueInjector uses the the proper mapping steps during runtime.
Jun 22, 2010 at 9:15 AM
Edited Jun 22, 2010 at 9:22 AM

ValueInjecter is not doing mapping from an instance of a specific type to another instance of a specific type, instead, the mapping is done from some specific properties in the source object (by name, type, value) to some specific properties in the destination object (the type of the source/destination doesn't matter).


if you have a ValueInjection that maps from Foo -> Bar then you can use it to inject values from any type that has propertie(s) of type Foo to any type that has propertie(s) of type Bar.

in your case it could be something like this:




another thing is using the ValueInjecter inside a ValueInjection when you are mapping a more complex property type