Created
March 18, 2018 06:26
-
-
Save lbargaoanu/904b4d6ed3ab38581df0a1a93939aae7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 static void Main(string[] args) | |
{ | |
Mapper.Initialize(cfg => | |
{ | |
cfg.CreateMap<PartType, Part>(); | |
}); | |
Mapper.AssertConfigurationIsValid(); | |
var result = Mapper.Map<Part>(GetPart()).Dump(); | |
} | |
public class Part | |
{ | |
public string PartName { get; set; } | |
public string PartNumber { get; set; } | |
public string PartPosition { get; set; } | |
public IList<Part> PartReplacedBy = new List<Part>(); | |
} | |
public class PartType | |
{ | |
public string PartNumber { get; set; } | |
public PartInformationType Part { get; set; } | |
} | |
public class PartInformationType | |
{ | |
public string Position { get; set; } | |
public string Name { get; set; } | |
public IList<PartType> ReplacedBy = new List<PartType>(); | |
} | |
private static PartType GetPart() | |
{ | |
var PartTypeInfo = new PartInformationType | |
{ | |
Name = "SomeName", | |
Position = "2", | |
ReplacedBy = new List<PartType> | |
{ | |
new PartType | |
{ | |
PartNumber = "22", | |
Part = new PartInformationType | |
{ | |
Name = "SomeSubName" | |
} | |
}, | |
new PartType | |
{ | |
PartNumber = "33", | |
Part = new PartInformationType | |
{ | |
Name = "33SubName", | |
Position = "33SubPosition", | |
ReplacedBy = new List<PartType> | |
{ | |
new PartType | |
{ | |
PartNumber = "444", | |
Part = new PartInformationType | |
{ | |
Name = "444SubSubname" | |
} | |
} | |
} | |
} | |
} | |
} | |
}; | |
var part = new PartType | |
{ | |
PartNumber = "1", | |
Part = PartTypeInfo | |
}; | |
return part; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment