c# - How to map property of type `Object` with different datatypes to a corresponding classtype? -


i have 2 classes:

public class a{ [system.xml.serialization.xmlelementattribute("type1", typeof(xmlitemtype1), isnullable=true)] [system.xml.serialization.xmlelementattribute("type2", typeof(xmlitemtype2), isnullable=true)] public object item { get; set; } }  public class b{ public object item { get; set; } } 

mapping created follows:

automapper.mapper.createmap<a, b>() .formember(domainobject => domainobject.item , metadata => metadata.mapfrom(xmlobject => xmlobject.item ));   automapper.mapper.createmap<xmlitemtype1, xmlobjecttype1>(); automapper.mapper.createmap<xmlitemtype2, xmlobjecttype2>();  automapper.mapper.map<a, b>(data);             

but output property of b class item of type xmlitemtype1 instead of xmlobjecttype1.

how can make sure after mapping item of type xmlobjecttype1 or xmlobjecttype2?


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -