Ejemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="contactPhoneList">
        /// A <see cref="ContactPhone[]"/>
        /// </param>
        /// <returns>
        /// A <see cref="ABMultiValue<System.String>"/>
        /// </returns>
        private ABMultiValue<string> ConvertContactPhonesToNative(ContactPhone[] contactPhoneList)
        {
            ABMutableStringMultiValue multableMultilabel = new ABMutableStringMultiValue();

            if(contactPhoneList!=null) {
                foreach(ContactPhone contactPhone in contactPhoneList) {

                    NSString label = ABLabel.Other; // default is "Other"
                    if(contactPhone.Type == NumberType.Other && contactPhone.IsPrimary) {
                        label = ABPersonPhoneLabel.Main;
                    } else if(contactPhone.Type == NumberType.Pager) {
                        label = ABPersonPhoneLabel.Pager;
                    } else if(contactPhone.Type == NumberType.Mobile) {
                        label = ABPersonPhoneLabel.Mobile;
                    } else if(contactPhone.Type == NumberType.WorkFax) {
                        label = ABPersonPhoneLabel.WorkFax;
                    } else if(contactPhone.Type == NumberType.HomeFax) {
                        label = ABPersonPhoneLabel.HomeFax;
                    } else if(contactPhone.Type == NumberType.Work) {
                        label = ABLabel.Work;
                    } else if(contactPhone.Type == NumberType.FixedLine) {
                        label = ABLabel.Home;
                    }

                    multableMultilabel.Add(contactPhone.Number, label);
                }
            }

            return multableMultilabel;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="person">
        /// A <see cref="ABPerson"/>
        /// </param>
        /// <returns>
        /// A <see cref="ContactPhone[]"/>
        /// </returns>
        private ContactPhone[] GetContactPhones(ABPerson person)
        {
            List<ContactPhone> contactPhoneList = new List<ContactPhone>();

            if(person != null) {
                ABMultiValue<string> phones = person.GetPhones();
                if(phones!=null) {

                    IEnumerator enumerator = phones.GetEnumerator();
                    while(enumerator.MoveNext()){
                        object currentPhone = enumerator.Current;
                        string label = ((ABMultiValueEntry<string>)currentPhone).Label;
                        string phone = ((ABMultiValueEntry<string>)currentPhone).Value;

                        ContactPhone contactPhone = new ContactPhone();
                        contactPhone.Number = phone;

                        if(label == ABLabel.Home) {
                            contactPhone.Type = NumberType.FixedLine;
                        } else if(label == ABLabel.Work) {
                            contactPhone.Type = NumberType.Work;
                        } else if(label == ABPersonPhoneLabel.HomeFax) {
                            contactPhone.Type = NumberType.HomeFax;
                        } else if(label == ABPersonPhoneLabel.WorkFax) {
                            contactPhone.Type = NumberType.WorkFax;
                        } else if(label == ABPersonPhoneLabel.Mobile) {
                            contactPhone.Type = NumberType.Mobile;
                        } else if(label == ABPersonPhoneLabel.Pager) {
                            contactPhone.Type = NumberType.Pager;
                        } else if (label == ABPersonPhoneLabel.Main) {
                            contactPhone.Type = NumberType.Other;
                            contactPhone.IsPrimary = true;
                        } else {
                            contactPhone.Type = NumberType.Other;
                        }

                        contactPhoneList.Add(contactPhone);
                    }
                }
            }
            return contactPhoneList.ToArray();
        }
Ejemplo n.º 3
0
        private ContactPhone[] GetContactPhonesArray(Windows.ApplicationModel.Contacts.Contact contact)
        {
            var phoneList = new List<ContactPhone>();

            foreach (var phone in contact.Phones.Where(phone => !String.IsNullOrWhiteSpace(phone.Number)))
            {
                var conPhone = new ContactPhone { Number = phone.Number };
                switch (phone.Kind)
                {
                    case ContactPhoneKind.Home:
                        conPhone.Type = NumberType.FixedLine;
                        break;

                    case ContactPhoneKind.Mobile:
                        conPhone.Type = NumberType.Mobile;
                        break;

                    case ContactPhoneKind.Work:
                        conPhone.Type = NumberType.Work;
                        break;

                    default:
                        conPhone.Type = NumberType.Other;
                        break;
                }
                phoneList.Add(conPhone);
            }
            return phoneList.ToArray();
        }