Created
September 13, 2011 19:29
-
-
Save KevM/1214820 to your computer and use it in GitHub Desktop.
Automapper Fubu ideas?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //My advice (YMMV) : | |
| // | |
| //skip the view filter | |
| //Only expose your normal U type actions to the action scanner (source) | |
| //add a covention that prepends your U type actions with the appropriate automapperaction<T,U> | |
| // * your devices to know what T goes with what U | |
| public class AutoMapperConvention : IConfigurationAction | |
| { | |
| public void Configure(BehaviorGraph graph) | |
| { | |
| var autoMappedCalls = graph.Actions().Where(call => call.IsAutoMappedHandler()); | |
| autoMappedCalls.Each(action => | |
| { | |
| var mapOutputType = action.InputType(); | |
| var mapInputType = //automap registry has this? | |
| //var wrapActionWith = make generic authmapperaction type | |
| var actionType = typeof(AutoMapAction<,>).MakeGenericType(mapInputType, mapOutputType); | |
| var method = actionType.GetMethod("Get"); | |
| var mapAction = new ActionCall(actionType, method); | |
| action.WrapWith(mapAction); | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment