2

is it possible to inject from something like this :

public class DomainEntity
{
    public Resource DescriptionResource { get; set; }
}

public class Resource
{
    public List<ResourceLocalization> Localizations { get; set; }
}

public class ResourceLocalization
{
    public string Culture { get; set; }
    public string Value { get; set; }
}

to something like this:

public class DomainEntityViewModel
{
    public string Description { get; set; }
}

(DomainEntity.DescriptionResource.Localizations.First().Value => DomainEntityViewModel.Description)

using ValueInjecter.

Thank You!

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
shkipper
  • 1,403
  • 3
  • 21
  • 35

1 Answers1

2

you could use this injection :

    public class MyInj : ConventionInjection
    {
        protected override bool Match(ConventionInfo c)
        {
            return c.TargetProp.Name == c.SourceProp.Name 
            && c.TargetProp.Type == typeof (string) 
            && c.SourceProp.Type == typeof (List<ResourceLocalization>);
        }
        protected override object SetValue(ConventionInfo c)
        {
            return ((List<ResourceLocalization>) c.SourceProp.Value).First().Value;
        }
    }
Omu
  • 69,856
  • 92
  • 277
  • 407