У меня есть средство форматирования
public class ColorFormatter : IValueFormatter
{
public string FormatValue(ResolutionContext context)
{
return "green"
}
}
Mapper.CreateMap<MyClass, MyViewModel>().ForMember(dest => dest.color, opt => opt.AddFormatter<ColorFormatter>());
В MyClass нет ничего с именем bgColor, но у MyViewModel есть, и я хочу, чтобы у всех bgColors был "зеленый".
Так почему он не запускается?
Все остальное в MYClass успешно отображается на MyViewModel.
List<MyViewModel> vm = Mapper.Map<List<MyClass>, List<MyViewModel>>(myClasses);
[Serializable]
public class MyClass
{
public virtual int Id { get; private set; }
public virtual string Title { get; set; }
public virtual DateTime Start { get; set; }
public virtual DateTime End { get; set; }
public virtual string Description { get; set; }
public virtual string Where { get; set; }
public virtual bool AllDay { get; set; }
public virtual AnotherClass AnotherClass { get; set; }
public virtual int RepeatingId { get; set; }
}
public class MyViewModel
{
public int id { get; set; }
public string title { get; set; }
public bool allDay { get; set; }
public string start { get; set; }
public string end { get; set; }
public string color { get; set; }
public string appointmentId { get; set; }
public string textColor { get; set; }
}