I am trying to get my hands on ValueInjector having used Automapper in the past. I want to convert one enum to another where only the enum names are different but the property name and values are same.
public enum GenderModel
{
NotSpecified = 0,
Male = 1,
Female = 2
}
public enum GenderDto
{
NotSpecified = 0,
Male = 1,
Female = 2
}
Then I am trying to map like this
var model = GenderModel.Male;
var dto = GenderDto.NotSpecified;
dto.InjectFrom(model);
I am expecting to get Male in dto object but it is still set to NotSpecified.
What am I missing? Please guide.
In my opinion,
ValueInjectercan not map value types such asenum, struct, int, double. Or no need map for value types. It only help to map class types' properties that have same name and type. To map enum for this example, I suggest,If the enum is nested in the specific class, the default ValueInjecter can not map
GenderModelandGenderDtobecause they are different type. So we can implement it by a customer ValueInjecter. This is my test code here, hope it can help.And the Main function code: