Ejemplo n.º 1
0
        internal void SetPeopleWhoLikeThisIds(IEnumerable <FacebookObjectId> likerIds)
        {
            // Should only be set during initialization
            Assert.IsNull(_mergeableLikers);

            _mergeableLikers = new FBMergeableCollection <FacebookContact>(from uid in likerIds select SourceService.GetUser(uid), false);
        }
Ejemplo n.º 2
0
 // Derived classes should not directly expose a constructor that calls through to this.
 // To ensure that this is really what the caller wants a static factory method is preferred.
 internal FacebookCollection(IEnumerable <T> items)
 {
     Assert.IsFalse(items is FBMergeableCollection <T>);
     Verify.IsNotNull(items, "items");
     _dispatcher       = Dispatcher.FromThread(Thread.CurrentThread);
     _sourceCollection = new FBMergeableCollection <T>(items);
 }
Ejemplo n.º 3
0
 internal FacebookPhoto(FacebookService service)
 {
     Assert.IsNotNull(service);
     SourceService = service;
     RawComments   = new FBMergeableCollection <ActivityComment>();
     RawTags       = new FBMergeableCollection <FacebookPhotoTag>();
 }
Ejemplo n.º 4
0
 private void IndexContacts(FBMergeableCollection <FacebookContact> friends)
 {
     lock (friends.SyncRoot)
     {
         foreach (FacebookContact friend in friends)
         {
             string[] words = GetWordsFromContact(friend);
             ReplaceForwardIndexItem(friend, words);
         }
     }
 }
Ejemplo n.º 5
0
 private void IndexComments(FBMergeableCollection <ActivityComment> comments)
 {
     lock (comments)
     {
         foreach (ActivityComment comment in comments)
         {
             string[] words = GetWordsFromComment(comment);
             ReplaceForwardIndexItem(comment, words);
         }
     }
 }
Ejemplo n.º 6
0
 // Light constructor for Attachment provided photos
 internal FacebookPhoto(FacebookService service, FacebookObjectId albumId, FacebookObjectId photoId, Uri source)
 {
     SourceService = service;
     AlbumId       = albumId;
     PhotoId       = photoId;
     Created       = default(DateTime);
     Link          = null;
     Image         = new FacebookImage(service, source);
     RawComments   = new FBMergeableCollection <ActivityComment>();
     RawTags       = new FBMergeableCollection <FacebookPhotoTag>();
 }
Ejemplo n.º 7
0
        internal FacebookCollection(FBMergeableCollection <T> rawCollection, FacebookService service)
        {
            Verify.IsNotNull(rawCollection, "rawCollection");
            Verify.IsNotNull(service, "service");

            Assert.IsTrue(service.Dispatcher.CheckAccess());
            _dispatcher = service.Dispatcher;

            _sourceCollection = rawCollection;
            SourceService     = service;
        }
Ejemplo n.º 8
0
 private void IndexAlbums(FBMergeableCollection <FacebookPhotoAlbum> albums)
 {
     lock (albums.SyncRoot)
     {
         foreach (FacebookPhotoAlbum album in albums)
         {
             string[] words = GetWordsFromAlbum(album);
             ReplaceForwardIndexItem(album, words);
             IndexPhotos(album);
         }
     }
 }
Ejemplo n.º 9
0
 private void IndexPosts(FBMergeableCollection <ActivityPost> posts)
 {
     lock (posts.SyncRoot)
     {
         foreach (ActivityPost post in posts)
         {
             string[] words = GetWordsFromPost(post);
             ReplaceForwardIndexItem(post, words);
             IndexComments(post.RawComments);
         }
     }
 }
Ejemplo n.º 10
0
        void IMergeable <FacebookObjectId, ActivityPost> .Merge(ActivityPost other)
        {
            Verify.IsNotNull(other, "other");
            Verify.AreEqual(PostId, other.PostId, "other", "Can't merge two ActivityPosts with different Ids.");

            if (object.ReferenceEquals(this, other))
            {
                return;
            }

            Assert.AreEqual(ActorUserId, other.ActorUserId);
            //ActorUserId = other.ActorUserId;
            Assert.AreEqual(TargetUserId, other.TargetUserId);
            //TargetUserId = other.TargetUserId;

            Attachment        = other.Attachment;
            CanComment        = other.CanComment;
            CanLike           = other.CanLike;
            CanRemoveComments = other.CanRemoveComments;
            CommentCount      = other.CommentCount;
            Created           = other.Created;
            HasLiked          = other.HasLiked;
            LikedCount        = other.LikedCount;
            LikeUri           = other.LikeUri;
            Message           = other.Message;
            RawComments.Merge(other.RawComments, false);
            if (_hasGottenMoreComments)
            {
                GetMoreComments();
            }
            else
            {
                _NotifyPropertyChanged("HasMoreComments");
            }

            if (other._mergeableLikers != null && other._mergeableLikers.Count != 0)
            {
                if (this._mergeableLikers == null)
                {
                    _mergeableLikers = new FBMergeableCollection <FacebookContact>(false);
                }
                _mergeableLikers.Merge(other._mergeableLikers, false);
            }
            else if (_mergeableLikers != null)
            {
                _mergeableLikers.Clear();
            }

            Updated = other.Updated;
        }
Ejemplo n.º 11
0
        internal FacebookPhotoAlbumCollection(FBMergeableCollection <FacebookPhotoAlbum> sourceCollection, FacebookService service, FacebookContact owner)
            : base(sourceCollection, service)
        {
            VerifyAccess();

            if (owner != null)
            {
                _rawCollection      = sourceCollection;
                _owner              = owner;
                _filteredCollection = new FBMergeableCollection <FacebookPhotoAlbum>(from album in sourceCollection where album.OwnerId == owner.UserId select album, false);
                base.ReplaceSourceCollection(_filteredCollection);
                sourceCollection.CollectionChanged += _OwnerFilterOnRawCollectionChanged;
            }
            // A null owner implicitly means that the album collection is filterable
            else
            {
                _interestMap = new Dictionary <FacebookContact, bool>();

                _rawCollection      = sourceCollection;
                _filteredCollection = new FBMergeableCollection <FacebookPhotoAlbum>(false);
                base.ReplaceSourceCollection(_filteredCollection);

                foreach (var album in sourceCollection)
                {
                    album.PropertyChanged += _OnAlbumOwnerUpdated;
                    if (album.Owner != null)
                    {
                        lock (_localLock)
                        {
                            if (!_interestMap.ContainsKey(album.Owner))
                            {
                                _interestMap.Add(album.Owner, _IsOwnerInteresting(album));
                                album.Owner.PropertyChanged += _OnContactPropertyChanged;
                            }
                        }
                        album.PropertyChanged -= _OnAlbumOwnerUpdated;

                        if (_IsOwnerInteresting(album))
                        {
                            _filteredCollection.Add(album);
                        }
                    }
                }

                sourceCollection.CollectionChanged += _InterestFilterOnRawCollectionChanged;
            }
        }
Ejemplo n.º 12
0
        internal FacebookContactCollection(FBMergeableCollection <FacebookContact> sourceCollection, FacebookService service, bool includeOnlyOnlineContacts)
            : base(sourceCollection, service)
        {
            if (includeOnlyOnlineContacts)
            {
                _onlineMap          = new Dictionary <FacebookContact, bool>();
                _rawCollection      = sourceCollection;
                _filteredCollection = new FBMergeableCollection <FacebookContact>(from buddy in sourceCollection where _IsOnline(buddy) select buddy, true);
                _filteredCollection.CustomComparison = FacebookContact.GetComparison(ContactSortOrder.AscendingByOnlinePresence);
                base.ReplaceSourceCollection(_filteredCollection);

                foreach (var buddy in sourceCollection)
                {
                    _onlineMap.Add(buddy, _IsOnline(buddy));
                    buddy.PropertyChanged += _OnContactPropertyChanged;
                }

                sourceCollection.CollectionChanged += _OnRawCollectionChanged;
            }
        }
Ejemplo n.º 13
0
        internal ActivityPostCollection(FBMergeableCollection <ActivityPost> sourceCollection, FacebookService service, bool filterable)
            : base(sourceCollection, service)
        {
            if (filterable)
            {
                _interestMap   = new Dictionary <FacebookContact, bool>();
                _rawCollection = sourceCollection;
                // Sort this filtered view same as the underlying collection.
                // If there's ever a custom sort on ActivityPosts, I need to add an INotifyPropertyChanged implementation to keep the sort orders in sync.
                _filteredCollection = new FBMergeableCollection <ActivityPost>(from post in sourceCollection where _IsInteresting(post.Actor) select post, true);
                base.ReplaceSourceCollection(_filteredCollection);

                foreach (var contact in from p in sourceCollection select p.Actor)
                {
                    _interestMap.Add(contact, _IsInteresting(contact));
                    contact.PropertyChanged += _OnContactPropertyChanged;
                }

                sourceCollection.CollectionChanged += _OnRawCollectionChanged;
            }
        }
Ejemplo n.º 14
0
 internal FacebookPhotoCollection(FBMergeableCollection <FacebookPhoto> rawCollection, FacebookService service)
     : base(rawCollection, service)
 {
 }
Ejemplo n.º 15
0
 internal ActivityCommentCollection(FBMergeableCollection <ActivityComment> rawCollection, FacebookService service)
     : base(rawCollection, service)
 {
 }
Ejemplo n.º 16
0
 internal SearchResults(FBMergeableCollection <object> rawCollection, FacebookService service, string searchText)
     : base(rawCollection, service)
 {
     this.SearchText = searchText;
 }
Ejemplo n.º 17
0
 internal FacebookContact(FacebookService service)
 {
     SourceService     = service;
     RawRecentActivity = new FBMergeableCollection <ActivityPost>(null);
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Be careful of adding new uses of this.
 /// This is only intended to be called within the constructor of derived classes.
 /// </summary>
 internal void ReplaceSourceCollection(FBMergeableCollection <T> newSource)
 {
     Assert.IsTrue(_sourceCollectionChanged == null);
     Assert.IsNotNull(newSource);
     _sourceCollection = newSource;
 }
Ejemplo n.º 19
0
 internal FacebookPhotoTagCollection(FBMergeableCollection <FacebookPhotoTag> tags, FacebookService service)
     : base(tags, service)
 {
 }