-
Notifications
You must be signed in to change notification settings - Fork 334
Interface base Code generation
chaowlert edited this page Jan 24, 2021
·
1 revision
Annotate your interface with [Mapper]
in order for tool to pickup for generation.
This is example interface.
[Mapper]
public interface IProductMapper
{
ProductDTO Map(Product customer);
}
You can add multiple members as you want. All member names are flexible, but signature must be in following patterns:
[Mapper]
public interface ICustomerMapper
{
//for queryable
Expression<Func<Customer, CustomerDTO>> ProjectToDto { get; }
//map from POCO to DTO
CustomerDTO MapToDto(Customer customer);
//map to existing object
Customer MapToExisting(CustomerDTO dto, Customer customer);
}
If you have configuration, it must be in IRegister
public class MyRegister : IRegister
{
public void Register(TypeAdapterConfig config)
{
config.NewConfig<TSource, TDestination>();
}
}
- Configuration
- Config inheritance
- Config instance
- Config location
- Config validation & compilation
- Config for nested mapping
- Custom member matching logic
- Constructor mapping
- Before & after mapping
- Setting values
- Shallow & merge mapping
- Recursive & object references
- Custom conversion logic
- Inheritance