ValueInjecter ignore cases when displaying properties

For example, I want to map the Foo.ID property to Bar.Id, is this possible?

+4
source share
1 answer

You need to create your own ConventionInjection , in which you compare the case of property names without special permissions:

 public class IgnoreCaseInjection : ConventionInjection { protected override bool Match(ConventionInfo c) { return String.Compare(c.SourceProp.Name, c.TargetProp.Name, StringComparison.OrdinalIgnoreCase) == 0; } } 

And you need to use it with

 var foo = new Foo() { ID = 1}; var bar = new Bar(); bar.InjectFrom<IgnoreCaseInjection>(foo); 
+5
source

All Articles