Last active
July 4, 2017 16:27
-
-
Save michaelaird/df1c79d944a8e9ce0fde51f149879bf0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class FormElement2 | |
{ | |
public Guid Id { get; set; } | |
public int Order { get; set; } | |
} | |
public abstract class FieldControl2 : FormElement2 | |
{ | |
public string Label { get; set; } | |
public string Trailer { get; set; } | |
public bool Prepoluate { get; set; } | |
} | |
public abstract class TextFieldControl2 : FieldControl2 | |
{ | |
public string DefaultValue { get; set; } | |
public int Size { get; set; } | |
} | |
public class TextBoxControl2 : TextFieldControl2 | |
{ | |
public int Rows { get; set; } | |
} | |
public abstract class FormControlBaseDTO2 | |
{ | |
public Guid Id { get; set; } | |
public int Order { get; set; } | |
} | |
public class FormElementDTO2 : FormControlBaseDTO2 | |
{ | |
public FormElementType ElementType { get; set; } | |
public string Label { get; set; } | |
public string Trailer { get; set; } | |
public string DefaultValue { get; set; } | |
public int Size { get; set; } | |
public int Rows { get; set; } | |
public bool Prepopulate { get; set; } | |
} | |
public class Scenario2 | |
{ | |
public static void Run() | |
{ | |
Mapper.Initialize(cfg => { | |
cfg.CreateMap<FormElement2, FormElementDTO2>(MemberList.None) | |
.Include<FieldControl2, FormElementDTO2>() | |
.Include<TextBoxControl2, FormElementDTO2>(); | |
cfg.CreateMap<FieldControl2, FormElementDTO2>(MemberList.None) | |
.Include<TextBoxControl2, FormElementDTO2>() | |
.ForMember(dto => dto.Prepopulate, opt => opt.MapFrom(src => src.Prepoluate)); | |
cfg.CreateMap<TextBoxControl2, FormElementDTO2>(MemberList.Source) | |
.ForMember(dto => dto.ElementType, opt => opt.UseValue(FormElementType.TextBox)); | |
}); | |
Mapper.AssertConfigurationIsValid(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment