예제 #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="addressBook">
        /// A <see cref="ABAddressBook"/>
        /// </param>
        /// <param name="requestedGroupName">
        /// A <see cref="System.String"/>
        /// </param>
        /// <returns>
        /// A <see cref="ABPerson[]"/>
        /// </returns>
        private ABPerson[] GetContactsByGroup(ABAddressBook addressBook, string requestedGroupName)
        {
            ABPerson [] people = new ABPerson[0];

            ABGroup[] groups = addressBook.GetGroups();

            foreach(ABGroup abGroup in groups) {
                if(abGroup.Name == requestedGroupName) {
                    ABRecord[] records = abGroup.GetMembers(DEFAULT_CONTACTS_LIST_SORT); //get list sorted by FirstName (default)
                    people = new ABPerson[records.Length];
                    for(int i=0; i< records.Length; i++) {
                        ABRecord record = records[i];
                        ABPerson person = addressBook.GetPerson(record.Id);
                        if(person!=null) {
                            people[i] = person;
                        }
                    }
                    break;
                }
            }
            return people;
        }