private static void Main(string[] args) { var newItem = new SourceDomain <Person> { Item = new Person { Age = 11 }, Name = "John" }; var oldItem = new DestinationDomain <Person> { Item = new Person { Age = 10 } }; //there is an item in a database which is of D1 type. This convertor receives an object S1 in order to update the D1 item. // the rule is that Sx updatates Dx (where x is 1,2,3,4,5...) Convertor <Person> convertor = new Convertor <Person>(newItem, oldItem); var newItem2 = new SourceDomain <Location>() { Item = new Location { City = "London" }, Name = "Lynda" }; var oldItem2 = new DestinationDomain <Location>() { Item = new Location { City = "Paris" } }; Convertor <Location> convertor2 = new Convertor <Location>(newItem2, oldItem2); Console.ReadKey(); }
public Convertor(SourceDomain <X> newObject, DestinationDomain <X> oldObject) { item = newObject; oldItem = oldObject; //here I want to call, depending of item type, the proper method, not the base one. //newObject.Data = oldItem.Data; oldItem.CopyItemFrom(item.Item); }