コード例 #1
0
        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;
        }
コード例 #2
0
ファイル: ContatoViewModel.cs プロジェクト: psoa/XF.Contatos
        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);
        }
コード例 #3
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);
        }
コード例 #4
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;
        }
コード例 #5
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);
        }
コード例 #6
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);
        }
コード例 #7
0
 public MockEmptyConversation(IEnumerable <IContact> contacts)
 {
     AssociatedContacts = new ContactList(contacts);
 }
コード例 #8
0
 public IActionResult AddContact([FromBody] IContactList contact)
 {
     this.contacts.Add(contact);
     return(CreatedAtRoute("GetSpecificItem", new { index = contacts.IndexOf(contact) }, contact));
 }
コード例 #9
0
ファイル: ContactList.cs プロジェクト: jzajac2/AllYourTexts
 public bool Equals(IContactList otherContactList)
 {
     return Enumerable.SequenceEqual(_contacts, otherContactList);
 }
コード例 #10
0
        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);
        }
コード例 #11
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;
        }
コード例 #12
0
 public ChatConversation(IEnumerable <IContact> assocaiatedContacts)
 {
     AssociatedContacts = new ContactList(assocaiatedContacts);
     AssociatedContacts.Sort(ContactComparer.CompareAlphabetically);
 }
コード例 #13
0
 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;
         }
     }
 }
コード例 #14
0
ファイル: ContactList.cs プロジェクト: cheunjq/AllYourTexts
 public bool Equals(IContactList otherContactList)
 {
     return(Enumerable.SequenceEqual(_contacts, otherContactList));
 }