public IResource AfterDeserialize(IResource parentResource, IResource phone, System.Xml.XmlNode node) { // Search for account only if we deal with completely consistent chain // of the resources - parent must be a Contact, resource must be a Phone if (parentResource.Type != "Contact" && phone.Type != "Phone") { throw new ArgumentException("PhoneDeserialization -- Illegal types of input parameters: [" + parentResource.Type + "] and [" + phone.Type + "]"); } ContactBO contact = new ContactBO(parentResource); string newPhoneNumber = phone.GetStringProp(ContactManager._propPhoneNumber); string newPhoneName = phone.GetStringProp(ContactManager._propPhoneName); // Do not add phone if it is number already exist (even under the // name possibly). IResource contactPhone = contact.GetPhoneByNumber(newPhoneNumber); if (contactPhone != null) { return(contactPhone); } // If the phone with such name already exist, find more suitable // name for a newly coming phone number - add numeric prefix for // its name. contactPhone = contact.GetPhoneByName(newPhoneName); if (contactPhone != null) { string newName = ContactManager.ComposeSuitablePhoneName(contact, newPhoneName); phone.SetProp(ContactManager._propPhoneName, newName); } return(phone); }