-
Notifications
You must be signed in to change notification settings - Fork 36
Configuration
Initialization is the preferred mode of configuring AutoMapper, and should be done once at application startup:
class CamelCaseToPascalCaseMappingProfile implements AutoMapperJs.IProfile {
profileName = 'CamelCaseToPascalCase';
// configuration etc. etc.
}
automapper.initialize((config: AutoMapperJs.IConfiguration) => {
config.createMap('fromKey', 'toKey');
config.addProfile(new PascalCaseToCamelCaseMappingProfile());
});
Mapping configuration is static and should not change/be modified.
You can set the source and destination naming conventions:
automapper.initialize((config: AutoMapperJs.IConfiguration) => {
config.sourceMemberNamingConvention = new AutoMapperJs.CamelCaseNamingConvention();
config.destinationMemberNamingConvention = new AutoMapperJs.PascalCaseNamingConvention();
});
This will map the following properties to each other:
propertyName -> PropertyName
You can also set this at a per profile level
class CamelCaseToPascalCaseMappingProfile implements AutoMapperJs.IProfile {
profileName = 'CamelCaseToPascalCase';
public configure() {
sourceMemberNamingConvention = new AutoMapperJs.CamelCaseNamingConvention();
destinationMemberNamingConvention = new AutoMapperJs.PascalCaseNamingConvention();
}
}
Some samples are already created. You can run the configuration samples:
- locally, after cloning this repository;
- directly from GitHub, using the configuration samples page url.
AutoMapperTS is Copyright © 2015 Bert Loedeman and other contributors under the MIT license.
Getting started
Mapping performance
Initialization (initialize)
Mapping configuration (createMap)
- forMember
- forSourceMember
- condition
- forAllMembers
- ignoreAllNonExisting
- convertToType
- convertUsing
- withProfile
Validation (assertConfigurationIsValid)
Mapping (map)
Currying
Custom type converters
Profiles
Chaining
Naming conventions
Asynchronous mapping
Flattening and nesting