Exemplo n.º 1
0
        public SearchResultsByType(IList <FriendViewModel> friends,
                                   IList <PhoneContact> contacts, IList <UserInfo> possible)
        {
            var groups = new Dictionary <string, PeopleInGroup <ISearchable> >();

            // Create groups.
            var friendsG = new PeopleInGroup <ISearchable>(AppResources.FriendsGroup);

            this.Add(friendsG);
            groups[AppResources.FriendsGroup] = friendsG;

            var contactsG = new PeopleInGroup <ISearchable>(AppResources.ContactsGroup);

            this.Add(contactsG);
            groups[AppResources.ContactsGroup] = contactsG;

            var possibleG = new PeopleInGroup <ISearchable>(AppResources.OtherUsersGroup);

            this.Add(possibleG);
            groups[AppResources.OtherUsersGroup] = possibleG;

            // Fill groups.
            groups[AppResources.FriendsGroup].AddRange(friends.ToArray());
            groups[AppResources.ContactsGroup].AddRange(contacts.ToArray());
            groups[AppResources.OtherUsersGroup].AddRange(possible.ToArray());
        }
Exemplo n.º 2
0
        public ContactsByFirstName(List <PhoneContact> contacts)
        {
            var groups = new Dictionary <string, PeopleInGroup <PhoneContact> >();

            foreach (char c in Groups)
            {
                var group = new PeopleInGroup <PhoneContact>(c.ToString());
                this.Add(group);
                groups[c.ToString()] = group;
            }

            foreach (PhoneContact contact in contacts)
            {
                groups[EntitiesHelpers.GetFirstNameKey(contact.ContactName)].Add(contact);
            }
        }
Exemplo n.º 3
0
        public FriendByFirstName(List <FriendViewModel> friends)
        {
            var groups = new Dictionary <string, PeopleInGroup <FriendViewModel> >();

            // Create hints group.
            var hintsGroup = new PeopleInGroup <FriendViewModel>(string.Empty);

            this.Add(hintsGroup);
            groups[string.Empty] = hintsGroup;

            // Create other groups.
            foreach (char c in Groups)
            {
                var group = new PeopleInGroup <FriendViewModel>(c.ToString());
                this.Add(group);
                groups[c.ToString()] = group;
            }

            // Separate friends by hints and categorized.
            var hints = friends.Where(f => f.HintOrder >= 0 && f.HintOrder < 5).ToList();

            hints.Sort((h1, h2) =>
            {
                if (h1.HintOrder == h2.HintOrder)
                {
                    return(0);
                }
                else if (h1.HintOrder > h2.HintOrder)
                {
                    return(1);
                }
                else
                {
                    return(-1);
                }
            });
            var categorized = friends.Except(hints).ToList();

            // Fill hints group.
            groups[string.Empty].AddRange(hints);

            // Fill categorized groups.
            foreach (FriendViewModel friend in categorized)
            {
                groups[EntitiesHelpers.GetFirstNameKey(friend.FullName)].Add(friend);
            }
        }