Is there a way to provide automation with the only source and for that type of source, automatic formatting based on the mapping Can it be determined from that to map?
For example, I have a type of fu and I want to always map it to the bar, but at the runtime, my code can get one of many common types.
Add Public T (T Entity) {// Mapping List var mapList = New Dictionary & lt; Type, type & gt; {{Type (foo), typef (bar)} {typefix, typef (sprocket)}}; // Based on the type of t, determine who we map for ... somehow! Var t = mapList [entity.GetType ()]; // what goes in ?? In the case of Fu, there will be times for ensuring diversity? Var Destination = Automar Mapper Map & lt; T, ?? & Gt; (Entity); } Any help is greatly appreciated. As the @tobsen says, a non-monetary surcharge should be what you want:
Add Public T (T Entity) {// Mapping List var mapList = New Dictionary & lt; Type, type & gt; {{Type (foo), typef (bar)} {typefix, typef (sprocket)}}; Source type type = typef (t); Type destinationType = mapList [sourceType]; Object Destination = AutoMapper.Mapper.Map (entity, source type, destination type); // ... rest code} Generic overload in my experience is only useful when you already know the source / destination type.
Comments
Post a Comment