views:

490

answers:

4

I would like to know if the other similar open source solutions in .NET world, especially for 2.0 framework

A: 

Yo can use CSLA.NET. It provides a Map function.

Jedi Master Spooky
A: 

Why not NHibernate?

+1  A: 

I've just stumbled upon ObjectCastor where the goal is:

Basically, it generates a new proxy class using the System.CodeDom machinery, which wraps the sourceType and implements the interfaceType interface. With the help of .NET Reflection, it goes over the members of the interfaceType type and generates the corresponding members in the proxy class. After that, it compiles the generated class utilizing the CodeDomProvider class and calling the CompileAssemblyFromDom method. At this point, the generated class is compiled, and the last thing to do is to create a new instance of the proxy class and provide the source object as a constructor. The full source code for the utility class and the demo application are available above in the downloads section.

This technique is now being used in CS Script. From the CSScript help file:

In version 2.3.3 CS-Script introduces new script hosting model Interface Alignment, which is an attractive alternative to the interface inheritance while loading/accessing scripts through interfaces.

This model allows manipulation with the the script by "aligning" it to the appropriate interface (DuckTyping). Important aspect of this approach is that the script execution is completely typesafe (as with any script accessed through an interface) but even more importantly the script does not have to implement the interface being used by the host application. In a way Interface Alignment is a forcible typecasting: typecast to interface is possible as long as the object has all methods defined in the interface . This promising technique allows high level of decoupling between the host and the script business logic without any type safety compromise.

David Robbins
+1  A: 

I found out about otis in this answer. It uses String attributes on the classes.

tobsen
this one really looks promising, much better than Automapper especially in terms of configuration handling (I very much prefer metadata attributes on classes in Otis than writing like a dozen CreateMap statements in Automapper).
mare