Skip to content

Instantly share code, notes, and snippets.

@lbargaoanu
Last active September 3, 2022 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lbargaoanu/9948bf66d452ba6b816252f9965143ee to your computer and use it in GitHub Desktop.
Save lbargaoanu/9948bf66d452ba6b816252f9965143ee to your computer and use it in GitHub Desktop.
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