/// <summary> /// AddressBookContact class constructor. /// <remarks>Creates new object with the selected fields of an existing contact</remarks> /// </summary> /// <param name="addressBookContact">Existing address book contact</param> /// <param name="fields">List of the fields to be used for creating new contact</param> public AddressBookContact(AddressBookContact addressBookContact, List <string> fields) { addressBookContact.GetType().GetProperties().ToList() .ForEach(x => { if (fields.Contains(x.Name)) { x.SetValue(this, x.GetValue(addressBookContact)); } }); }
public object Clone() { AddressBookContact clonedContact = new AddressBookContact(); this.GetType().GetProperties().ToList() .ForEach(x => { if (x.Name != "AddressDbId") { x.SetValue(clonedContact, x.GetValue(this)); } }); return(clonedContact); }