Exemplo n.º 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;
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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;
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 7
0
 public MockEmptyConversation(IEnumerable <IContact> contacts)
 {
     AssociatedContacts = new ContactList(contacts);
 }
Exemplo n.º 8
0
 public IActionResult AddContact([FromBody] IContactList contact)
 {
     this.contacts.Add(contact);
     return(CreatedAtRoute("GetSpecificItem", new { index = contacts.IndexOf(contact) }, contact));
 }
Exemplo n.º 9
0
 public bool Equals(IContactList otherContactList)
 {
     return Enumerable.SequenceEqual(_contacts, otherContactList);
 }
Exemplo n.º 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);
        }
Exemplo n.º 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;
        }
Exemplo n.º 12
0
 public ChatConversation(IEnumerable <IContact> assocaiatedContacts)
 {
     AssociatedContacts = new ContactList(assocaiatedContacts);
     AssociatedContacts.Sort(ContactComparer.CompareAlphabetically);
 }
Exemplo n.º 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;
         }
     }
 }
Exemplo n.º 14
0
 public bool Equals(IContactList otherContactList)
 {
     return(Enumerable.SequenceEqual(_contacts, otherContactList));
 }