c# - Specify more than one rule in ValueInjecter's ConventionInjection(s) -
i'm new valueinjecter. knew how match properties same name different caps:
public class ignorecaseinjection : conventioninjection { protected override bool match(conventioninfo c) { return string.compare(c.sourceprop.name, c.targetprop.name, stringcomparison.ordinalignorecase) == 0; } } and:
var foo = new foo() { id = 1}; var bar = new bar(); bar.injectfrom<ignorecaseinjection>(foo); this map foo.id bar.id. if have properties mapped using different rule? example, have foo.myprop (which enumerable of type fooenum) want map bar.myprop string (i mean store .tostring() representation of enum).
how can add rule converter? how code like?
so far, found solution in valueinjecter's documentation:
viewmodel.injectfrom(entity) .injectfrom<countrytolookup>(entity) .injectfrom<anythingelseyoumightimagine>(entity) .injectfrom(new stuffinjection(stuffrepository), anotherentity); and have code each of classes , make sure don't overlap
Comments
Post a Comment