Beispiel #1
0
        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);
        }
Beispiel #2
0
        [Test] public void CheckNormilizedPhoneComparing()
        {
            string    email   = "*****@*****.**";
            ContactBO contact = (ContactBO)Core.ContactManager.FindOrCreateContact(email, "Sergey Zhulin");

            contact.SetPhoneNumber("Home", " 123-78-90");
            IResource phone = contact.GetPhoneByNumber("_1.2.3.7.8.9.0");

            Assert.IsNotNull(phone);
            Assert.AreEqual(" 123-78-90", phone.GetStringProp("PhoneNumber"));
        }