コード例 #1
0
        private void RemoveContatosExistentes(List <Contato> contatos)
        {
            var telefonesDoArquivo = contatos.SelectMany(l => l.Telefones).ToList();

            List <ABPerson> contatosExistente =
                (from person in agenda.GetPeople()
                 where ((from phone in person.GetPhones()
                         where (telefonesDoArquivo.Exists(t => OitoDitigos(t.Numero) == OitoDitigos(phone.Value)))
                         select phone).Count() > 0)

                 select person).ToList();

            //Remove Contatos Existentes
            foreach (var contato in contatosExistente)
            {
                agenda.Remove(contato);
                agenda.Save();
            }
        }
コード例 #2
0
        private void PopulateContacts()
        {
            var addressBook = new ABAddressBook();
            var people      = addressBook.GetPeople();

            // clear address book
            foreach (var person in people)
            {
                addressBook.Remove(person);
            }

            addressBook.Save();

            var random = new Random();

            // create 200 random contacts
            foreach (var name in _names)
            {
                // create an ABRecordRef
                var record = new ABPerson();
                record.FirstName = name[0];
                record.LastName  = name[1];
                var phones = new ABMutableStringMultiValue();
                phones.Add(GeneratePhone(random).ToString(), ABPersonPhoneLabel.Mobile);

                if (random.Next() % 2 == 1)
                {
                    phones.Add(GeneratePhone(random).ToString(), ABPersonPhoneLabel.Main);
                }

                record.SetPhones(phones);

                addressBook.Add(record);
            }
            addressBook.Save();
        }
コード例 #3
0
        private void PopulateContacts()
        {
            var addressBook = new ABAddressBook();
            var people = addressBook.GetPeople();

            // clear address book
            foreach(var person in people)
            {
                addressBook.Remove(person);
            }

            addressBook.Save();

            var random = new Random();
            // create 200 random contacts
            foreach (var name in _names)
            {
              // create an ABRecordRef
                var record = new ABPerson();
                record.FirstName = name[0];
                record.LastName = name[1];
                var phones = new ABMutableStringMultiValue();
                phones.Add(GeneratePhone(random).ToString(), ABPersonPhoneLabel.Mobile);

                if(random.Next() % 2 == 1) {
                    phones.Add(GeneratePhone(random).ToString(), ABPersonPhoneLabel.Main);
                }

                record.SetPhones(phones);

                addressBook.Add(record);
            }
            addressBook.Save();
        }