I'm building a generic pretty-print method. One of the special types that I want to handle separately is KeyValuePair<TK,TV>
. In order to reduce the object to a known type, I thought I would map each KeyValuePair<TK,TV>
to a KeyValuePair<object, object>
.
The following code always produces 2 nulls in the Key
, Value
properties of proxy
.
Mapper.CreateMap(o.GetType(), typeof(KeyValuePair<object, object>));
var proxy = Mapper.Map<KeyValuePair<object, object>>(o);
This non-generic version, on the other hand, works as expected:
Mapper.CreateMap(o.GetType(), typeof(DictionaryEntry));
var proxy = Mapper.Map<DictionaryEntry>(o);
Why?
o
at this stage has been tested to be a KeyValuePair<,>
.
I'm using AutoMapper 3.2.1.0 on .NET 4.0.