Skip to content

Instantly share code, notes, and snippets.

@jstrassburg
Created March 30, 2014 04:41
Show Gist options
  • Save jstrassburg/9867646 to your computer and use it in GitHub Desktop.
Save jstrassburg/9867646 to your computer and use it in GitHub Desktop.
C# deep copy pattern using the AutoMapper library
// 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