Hi,
Maybe Spring.DataBinding.DataBindingManager and its use of Spring.Expressions in Spring.Core.dll is what you're looking for.
Since it's use is only little documented yet, here's a brief description of DataBindingManager. It only describes usage on webpages, but nothing prevents you from using it "standalone".
Here's a good description of Spring.Expressions.
I could imagine first defining some xml-format for describing the mapping:
Code:
<mappings>
<mapping src="propertyA1.propertxA2.propertyA3"
target=""propertyB1.propertyB2"
/>
<mapping ...
</mappings>
Second, write some code for reading in these mapping-definitions.
Third, build a DataBindingManager instance with Bindings according to the definitions:
Code:
DataBindingManager bindingMgr = new DataBindingManager();
foreach( Mapping m in mappings )
{
bindingMgr.AddBinding( m.Src, m.Target );
}
Finally use this bindingMgr instance for mapping the properties:
Code:
Model model;
DTO dto;
// model -> dto
ValidationErrors errors = new ValidationErrors();
bindingMgr.BindSourceToTarget( model, dto, errors );
// examine any errors here
// dto -> model
ValidationErrors errors = new ValidationErrors();
bindingMgr.BindTargetToSource( model, dto, errors );
// examine any errors here
Let us know, how you are doing. The possibility to externally describing DataBindings has been requested by others as well.
cheers,
Erich