Skip to content

Instantly share code, notes, and snippets.

@lbargaoanu
Last active September 3, 2022 12:34
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
var configurationExpression = new MapperConfigurationExpression();
configurationExpression.RemoveUnusedFeatures();
configurationExpression.AddProfile<MyMappings>();
var config = new MapperConfiguration(configurationExpression);
class MyMappings : Profile
{
public MyMappings()
{
this.RemoveUnusedFeatures();
}
}
public static void RemoveUnusedFeatures(this Profile profile)
{
var internalConfig = profile.Internal();
internalConfig.FieldMappingEnabled = false;
internalConfig.MethodMappingEnabled = false;
profile.ClearPrefixes();
profile.DisableConstructorMapping();
var memberConfig = internalConfig.MemberConfiguration;
memberConfig.DestinationNamingConvention = memberConfig.SourceNamingConvention = ExactMatchNamingConvention.Instance;
memberConfig.NameToMemberMappers.Clear();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment