Search code examples
c#valueinjecter

ValueInjecter injecting from a method


Is it posible to inject a value from a method using ValueInjecter ?

Similar to what AutoMapper do (GetTotal()) : https://github.com/AutoMapper/AutoMapper/wiki/Flattening

Thanks


Solution

  • it can be done, but you would have to create your own injection that will be able to do that: for example you could grab the code for SmartConvetionInjection

    http://valueinjecter.codeplex.com/wikipage?title=SmartConventionInjection

    and add the feature of matching property names to methods that Start with Get+ThatName

    atm only the properties are scanned, note the line

        var sourceProps = source.GetProps();
        var targetProps = target.GetProps();