private static int CompareBasedOnContactListSizeImpl(IContactList contactListA, IContactList contactListB) { int countA = contactListA.Count; int countB = contactListB.Count; if (countA == 0) { if (countB == 1) { // A is unknown sender, B is single known partner return 1; } else if (countB > 1) { // A is unknown sender, B is group chat return -1; } } else if ((countA > 1) && (countB <= 1)) { // A is group chat, B is single (known/unkonwn) partner return 1; } return 0; }
public ContatoViewModel() { IContactList contactList = DependencyService.Get <IContactList>(); try { Contatos = contactList.GetAllContacts(); } catch { App.Current.MainPage.DisplayAlert("Não foi possível carregar os contatos ", "Verifique as permissões do aplicativo", "Ok"); } EditCMD = new OnEditCMD(this); CallCMD = new OnCallCMD(this); }
private static int CompareContactListsAlphabetically(IContactList contactListA, IContactList contactListB) { int comparisons = Math.Min(contactListA.Count, contactListB.Count); for (int contactIndex = 0; contactIndex < comparisons; contactIndex++) { int contactCompare = ContactComparer.CompareAlphabetically(contactListA[contactIndex], contactListB[contactIndex]); if (contactCompare != 0) { return(contactCompare); } } return(contactListA.Count - contactListB.Count); }
private static int CompareBasedOnContactListSize(IContactList contactListA, IContactList contactListB) { int sizeCompare = CompareBasedOnContactListSizeImpl(contactListA, contactListB); if (sizeCompare != 0) { return sizeCompare; } sizeCompare = -1 * CompareBasedOnContactListSizeImpl(contactListB, contactListA); if (sizeCompare != 0) { return sizeCompare; } return 0; }
private static int CompareBasedOnContactListSize(IContactList contactListA, IContactList contactListB) { int sizeCompare = CompareBasedOnContactListSizeImpl(contactListA, contactListB); if (sizeCompare != 0) { return(sizeCompare); } sizeCompare = -1 * CompareBasedOnContactListSizeImpl(contactListB, contactListA); if (sizeCompare != 0) { return(sizeCompare); } return(0); }
private ContactList CoalesceContactLists(IContactList contactListA, IContactList contactListB) { Dictionary <long, IContactList> hashByContactId = new Dictionary <long, IContactList>(); HashByContactId(hashByContactId, contactListA); HashByContactId(hashByContactId, contactListB); ContactList mergedContacts = new ContactList(); foreach (IContactList contactListById in hashByContactId.Values) { IContact contactMerged = contactListById[0]; for (int contactIndex = 1; contactIndex < contactListById.Count; contactIndex++) { IContact contactCurrent = contactListById[contactIndex]; contactMerged = new MergedContact(contactMerged, contactCurrent); } mergedContacts.Add(contactMerged); } return(mergedContacts); }
public MockEmptyConversation(IEnumerable <IContact> contacts) { AssociatedContacts = new ContactList(contacts); }
public IActionResult AddContact([FromBody] IContactList contact) { this.contacts.Add(contact); return(CreatedAtRoute("GetSpecificItem", new { index = contacts.IndexOf(contact) }, contact)); }
public bool Equals(IContactList otherContactList) { return Enumerable.SequenceEqual(_contacts, otherContactList); }
private static int CompareBasedOnContactListSizeImpl(IContactList contactListA, IContactList contactListB) { int countA = contactListA.Count; int countB = contactListB.Count; if (countA == 0) { if (countB == 1) { // A is unknown sender, B is single known partner return(1); } else if (countB > 1) { // A is unknown sender, B is group chat return(-1); } } else if ((countA > 1) && (countB <= 1)) { // A is group chat, B is single (known/unkonwn) partner return(1); } return(0); }
private static int CompareContactListsAlphabetically(IContactList contactListA, IContactList contactListB) { int comparisons = Math.Min(contactListA.Count, contactListB.Count); for (int contactIndex = 0; contactIndex < comparisons; contactIndex++) { int contactCompare = ContactComparer.CompareAlphabetically(contactListA[contactIndex], contactListB[contactIndex]); if (contactCompare != 0) { return contactCompare; } } return contactListA.Count - contactListB.Count; }
public ChatConversation(IEnumerable <IContact> assocaiatedContacts) { AssociatedContacts = new ContactList(assocaiatedContacts); AssociatedContacts.Sort(ContactComparer.CompareAlphabetically); }
private void HashByContactId(Dictionary <long, IContactList> hashByContactId, IContactList contactList) { foreach (IContact contact in contactList) { IContactList hashedContactList; if (hashByContactId.ContainsKey(contact.ContactId)) { hashedContactList = hashByContactId[contact.ContactId]; hashedContactList.Add(contact); } else { hashedContactList = new ContactList(); hashedContactList.Add(contact); hashByContactId[contact.ContactId] = contactList; } } }
public bool Equals(IContactList otherContactList) { return(Enumerable.SequenceEqual(_contacts, otherContactList)); }