Created
April 28, 2015 13:45
-
-
Save ADelRosarioH/3f98f708c54c9beb2982 to your computer and use it in GitHub Desktop.
Simple Object to Object Mapper.
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
public sealed class Mapper | |
{ | |
public delegate void Rule<F, T>(F from, T to) | |
where F : class | |
where T : class; | |
public static T Map<F, T>(F primary, params Rule<F, T>[] rules) | |
where F : class | |
where T : class | |
{ | |
T secondary = Activator.CreateInstance<T>(); | |
foreach (var rule in rules) | |
{ | |
rule.Invoke(primary, secondary); | |
} | |
return secondary; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment