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); }
// 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); }
internal FacebookPhoto(FacebookService service) { Assert.IsNotNull(service); SourceService = service; RawComments = new FBMergeableCollection <ActivityComment>(); RawTags = new FBMergeableCollection <FacebookPhotoTag>(); }
private void IndexContacts(FBMergeableCollection <FacebookContact> friends) { lock (friends.SyncRoot) { foreach (FacebookContact friend in friends) { string[] words = GetWordsFromContact(friend); ReplaceForwardIndexItem(friend, words); } } }
private void IndexComments(FBMergeableCollection <ActivityComment> comments) { lock (comments) { foreach (ActivityComment comment in comments) { string[] words = GetWordsFromComment(comment); ReplaceForwardIndexItem(comment, words); } } }
// 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>(); }
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; }
private void IndexAlbums(FBMergeableCollection <FacebookPhotoAlbum> albums) { lock (albums.SyncRoot) { foreach (FacebookPhotoAlbum album in albums) { string[] words = GetWordsFromAlbum(album); ReplaceForwardIndexItem(album, words); IndexPhotos(album); } } }
private void IndexPosts(FBMergeableCollection <ActivityPost> posts) { lock (posts.SyncRoot) { foreach (ActivityPost post in posts) { string[] words = GetWordsFromPost(post); ReplaceForwardIndexItem(post, words); IndexComments(post.RawComments); } } }
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; }
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; } }
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; } }
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; } }
internal FacebookPhotoCollection(FBMergeableCollection <FacebookPhoto> rawCollection, FacebookService service) : base(rawCollection, service) { }
internal ActivityCommentCollection(FBMergeableCollection <ActivityComment> rawCollection, FacebookService service) : base(rawCollection, service) { }
internal SearchResults(FBMergeableCollection <object> rawCollection, FacebookService service, string searchText) : base(rawCollection, service) { this.SearchText = searchText; }
internal FacebookContact(FacebookService service) { SourceService = service; RawRecentActivity = new FBMergeableCollection <ActivityPost>(null); }
/// <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; }
internal FacebookPhotoTagCollection(FBMergeableCollection <FacebookPhotoTag> tags, FacebookService service) : base(tags, service) { }