One of the main features of MappingGenerator is generating implementation for mapping methods. Every method, which signature meets the criteria described in the paragraphs below, can be implemented by MappingGenerator. Both types of methods - synchronous and asynchronous - are supported. To generate the implementation:
ctr + . or alt + enter for Resharper users)🔥 Generate mapping code from the action menuA non-void method that takes a single parameter
public UserDTO Map(UserEntity entity)
{
throw new NotImplementedException();
}
Example:
A void method that takes two complex parameters
public void Update(UserDTO source, UserEntity target)
{
throw new NotImplementedException();
}
Example:
Void member method that takes a single complex parameter
public void UpdateWith(UserEntity en)
{
throw new NotImplementedException();
}
Example:
Void member method with more than one parameter
public void UpdateWith(string firstName, string lastName, int age)
{
throw new NotImplementedException();
}
Example:
Constructor method that takes a single complex parameter
public UserDTO(UserEntity user)
{
throw new NotImplementedException();
}
Example:
Constructor method that takes more than one parameter
public UserDTO(string firstName, string lastName, int age)
{
throw new NotImplementedException();
}
Example:
A non-void method that accepts no parameters.
public UserEntity ToEntity()
{
throw new NotImplementedException();
}
Example:
MappingGenerator supports asynchronous counterparts of all method types mentioned in Synchronous mappings section (when applicable). Every asynchronous method can optionally accept CancellationToken parameter. Both Task and ValueTask return types are supported.
public Task<UserDTO> Map(UserEntity entity, CancellationToken token)
{
throw new NotImplementedException();
}