public static IMapper Instance;
public static MapperConfiguration Config;
public static void Main()
Config = new MapperConfiguration(config =>
config.CreateMap<Appliance, ZTP>()
.ForMember(dest => dest.DeviceName, opt => opt.MapFrom(src => src.Name))
.ForMember(dest => dest.HcsVersion, opt => opt.MapFrom(src => src.Version));
config.CreateMap<Network, ZTP>()
.ForMember(dest => dest.Port, opt => opt.MapFrom(src => src.PortNumber))
.ForMember(dest => dest.Ipv4, opt => opt.MapFrom(src => src.Address));
config.CreateMap<WebProxy, ZTP>()
.ForMember(dest => dest.IsEnabled, opt => opt.MapFrom(src => src.WebProxyEnabled));
Instance = Config.CreateMapper();
Appliance app = new Appliance("Device1", "1.1", "loc");
Network network = new Network("8080", "1.2.3.4");
WebProxy proxy = new WebProxy(true);
Instance.Map<Appliance, ZTP>(app, ztp);
Instance.Map<Network, ZTP>(network, ztp);
Instance.Map<WebProxy, ZTP>(proxy, ztp);
Console.WriteLine("Device Name: " + ztp.DeviceName);
Console.WriteLine("Device Version: " + ztp.HcsVersion);
Console.WriteLine("Network Port: " + ztp.Port);
Console.WriteLine("Device IP: " + ztp.Ipv4);
Console.WriteLine("Device WebProxy Enabled: " + ztp.IsEnabled);
public string Name { get; set; }
public string Version { get; set; }
public string DeviceLoaction {get; set;}
public Appliance(string name, string version, string location)
this.DeviceLoaction = location;
public string PortNumber { get; set; }
public string Address { get; set; }
public Network(string port, string address)
public bool WebProxyEnabled { get; set; }
public WebProxy(bool enabled)
this.WebProxyEnabled = enabled;
public string DeviceName { get; set; }
public string HcsVersion { get; set; }
public string Port { get; set; }
public string Ipv4 { get; set; }
public bool IsEnabled { get; set; }