Shallow and Deep

Mar 17, 2011 at 3:34 PM

Hi guys, I am writing some tests using EmitMapper before adopting it as a "clone" technology in our Domains.

I believe the tool is very well done, I also used AutoMapper in the past and I can "feel" the speed difference. I have just a question
for you as I can't find yet documentation about this topic.

On a complex object like Person 1-* Address what is the "default" behavior for the mapper? Shallow or Deep?

If I do not specify the conventions Shallow and Deep how Emitmapper will do it by default?

Thanks 

Jun 14, 2013 at 8:29 AM
Good question considering it is an object mapper! I am surprised it is not clearly mentioned and further surprised it seems to be shallow by default:
    public class A 
    {
        public int ValueType { get; set; }
    }

    public class B
    {
        public A A { get; set; }
    }

    public class C
    {
        public A A { get; set; }
    }

    private static void Main(string[] args)
    {
        var b = new B();
        b.A = new A();
        var c = ObjectMapperManager.DefaultInstance.GetMapper<B, C>().Map(b);

        Console.WriteLine("EmitMapper uses {0} clone by default!", ReferenceEquals(b.A, c.A) ? "SHALLOW" : "DEEP");
    }
Outputs:
EmitMapper uses SHALLOW clone by default!