Created
          March 30, 2014 04:41 
        
      - 
      
- 
        Save jstrassburg/9867646 to your computer and use it in GitHub Desktop. 
    C# deep copy pattern using the AutoMapper library
  
        
  
    
      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
    
  
  
    
  | // Uses: AutoMapper | |
| // Install via NuGet w/ | |
| // PM> Install-Package AutoMapper | |
| using AutoMapper | |
| public class DeepCopyableClass | |
| { | |
| static DeepCopyableClass() | |
| { | |
| // Do whatever fancy copy stuff you need here | |
| Mapper.CreateMap<DeepCopyableClass, DeepCopyableClass>(); | |
| } | |
| public void DeepCopyFrom(DeepCopyableClass source) | |
| { | |
| Mapper.Map(source, this); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment