Skip to content

Instantly share code, notes, and snippets.

@bitsprint
Created June 7, 2013 08:32
Show Gist options
  • Select an option

  • Save bitsprint/5727864 to your computer and use it in GitHub Desktop.

Select an option

Save bitsprint/5727864 to your computer and use it in GitHub Desktop.
AutoMapper Domain To ViewModel Profile
namespace Web.Profiles.DomainToViewModel
{
using System.Linq;
using System.Reflection;
using AutoMapper;
using Core.Extensions;
public partial class DomainToViewModel : Profile
{
public override string ProfileName
{
get { return this.GetType().Name; }
}
protected override void Configure()
{
this.GetType()
.GetMethods(BindingFlags.NonPublic | BindingFlags.Instance)
.Where(x => x.IsFamily && x.Name != "Configure" && x.Name.Contains("Configure"))
.ForEach(method => method.Invoke(this, new object[] { }));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment