It’s really easy. ReSharper doesn’t do it, but you can use a super duper REGEX!
In Visual Studio:
public string Email { get; set; }
public string CellPhone { get; set; }
public int NumChildren { get; set; }
public DateTime BirthDate { get; set; }
-
Select all your properties. Hit CTRL-D to copy down.
-
Now hit CTRL-H to replace. Make sure
.*is selected for Regex matching. -
Replace:
public [\w?]* (\w*) .*(This Regex may need to be tweaked) -
With:
dest.$1 = source.$1;
Now you have some beautiful code you can put in a method of your choosing:
dest.Email = source.Email;
dest.CellPhone = source.CellPhone;
dest.NumChildren = source.NumChildren;
dest.BirthDate = source.BirthDate;
EDIT: New alternatives
- You can use AutoMapper for dynamic runtime mapping.
- Mapping Generator is really nice for static mapping. It can generate the code above and it works well with R#.