/// <summary> /// Takes the list of address book metafields and generates a list of /// ProcessedAddressBook objects. /// </summary> /// <param name="metaList">List of address book records to be filtered.</param> /// <returns>A list of processed address book records.</returns> private List <ProcessedAddressBook> GetAdrBookEntries(List <MetaField> metaList) { List <ProcessedAddressBook> pList = new List <ProcessedAddressBook>(); foreach (MetaAddressBookEntry mf in metaList) { ProcessedAddressBook pab = new ProcessedAddressBook(mf); // Save numbers and names for later cross referencing. AddNumber(adrBookNumbersFull, mf.Number); AddNumber(adrBookNumbers7, mf.SevenDigit); AddRecordToDict(adrBookNames, mf.Name, pab); AddRecordToDict(adrBookSevenDigits, mf.SevenDigit, pab); pList.Add(pab); } return(pList); }
public AddressBookListViewItem(ProcessedAddressBook addressBook) : base() { this.AddressBook = addressBook; }
/// <summary> /// Add an address book to a dictionary using a key, e.g., number or name. Use a list /// for key collisions. /// </summary> /// <param name="dict"></param> /// <param name="key"></param> /// <param name="pab"></param> private void AddRecordToDict(Dictionary <string, List <ProcessedAddressBook> > dict, string key, ProcessedAddressBook pab) { if (!dict.ContainsKey(key)) { List <ProcessedAddressBook> list = new List <ProcessedAddressBook>(); list.Add(pab); dict.Add(key, list); } else { dict[key].Add(pab); } }
/// <summary> /// For an address book entry: does this filter affect it? /// </summary> /// <param name="pab"></param> /// <returns></returns> public FilterResult IsFiltered(ProcessedAddressBook pab) { switch (fieldType) { case FieldType.PHONENUM: break; case FieldType.NAME: if (filterType == FilterType.HASCHAR) { return CharsCheck(pab.MetaData.Name); } break; default: break; } return FilterResult.NOTAPPLICABLE; }
/// <summary> /// Cycle through the list of address book filters to determine if the /// supplied entry should be filtered. /// </summary> /// <param name="pab"></param> /// <returns>True if it should be filtered, false if it should be kept.</returns> public bool IsFiltered(ProcessedAddressBook pab) { foreach (Filter filter in abFilters) { switch (filter.IsFiltered(pab)) { case Filter.FilterResult.NOTAPPLICABLE: break; case Filter.FilterResult.ACCEPT: return false; case Filter.FilterResult.REJECT: return true; } } // Default is to keep the record. return false; }
/// <summary> /// Takes the list of address book metafields and generates a list of /// ProcessedAddressBook objects. /// </summary> /// <param name="metaList">List of address book records to be filtered.</param> /// <returns>A list of processed address book records.</returns> private List<ProcessedAddressBook> GetAdrBookEntries(List<MetaField> metaList) { List<ProcessedAddressBook> pList = new List<ProcessedAddressBook>(); foreach (MetaAddressBookEntry mf in metaList) { ProcessedAddressBook pab = new ProcessedAddressBook(mf); // Save numbers and names for later cross referencing. AddNumber(adrBookNumbersFull, mf.Number); AddNumber(adrBookNumbers7, mf.SevenDigit); AddRecordToDict(adrBookNames, mf.Name, pab); AddRecordToDict(adrBookSevenDigits, mf.SevenDigit, pab); pList.Add(pab); } return pList; }
/// <summary> /// Add an address book to a dictionary using a key, e.g., number or name. Use a list /// for key collisions. /// </summary> /// <param name="dict"></param> /// <param name="key"></param> /// <param name="pab"></param> private void AddRecordToDict(Dictionary<string, List<ProcessedAddressBook>> dict, string key, ProcessedAddressBook pab) { if (!dict.ContainsKey(key)) { List<ProcessedAddressBook> list = new List<ProcessedAddressBook>(); list.Add(pab); dict.Add(key, list); } else { dict[key].Add(pab); } }