Skip to content

Instantly share code, notes, and snippets.

@lbargaoanu
Created March 18, 2018 06:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lbargaoanu/904b4d6ed3ab38581df0a1a93939aae7 to your computer and use it in GitHub Desktop.
Save lbargaoanu/904b4d6ed3ab38581df0a1a93939aae7 to your computer and use it in GitHub Desktop.
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