private async Task InitializeCollection() { Task <IEnumerable <long> > reader; switch (_type) { case RelationDataType.Following: reader = UserProxy.GetFollowingsAsync(_parent.AccountId); break; case RelationDataType.Follower: reader = UserProxy.GetFollowersAsync(_parent.AccountId); break; case RelationDataType.Blocking: reader = UserProxy.GetBlockingsAsync(_parent.AccountId); break; case RelationDataType.NoRetweets: reader = UserProxy.GetNoRetweetsAsync(_parent.AccountId); break; case RelationDataType.Mutes: reader = UserProxy.GetMutesAsync(_parent.AccountId); break; default: throw new ArgumentOutOfRangeException(); } await AddAsync(await reader.ConfigureAwait(false)).ConfigureAwait(false); }
/// <summary> /// Initialize account data info /// </summary> /// <param name="accountId">bound account id</param> public AccountRelationData(long accountId) { this._accountId = accountId; // load data from db InitializeCollection(() => UserProxy.GetFollowingsAsync(accountId), _followingLocker, _followings.Add, id => this.OnAccountDataUpdated(id, true, RelationDataChange.Following)); InitializeCollection(() => UserProxy.GetFollowersAsync(accountId), _followersLocker, _followers.Add, id => this.OnAccountDataUpdated(id, true, RelationDataChange.Follower)); InitializeCollection(() => UserProxy.GetBlockingsAsync(accountId), _blockingsLocker, _blockings.Add, id => this.OnAccountDataUpdated(id, true, RelationDataChange.Blocking)); InitializeCollection(() => UserProxy.GetNoRetweetsAsync(accountId), _noRetweetsLocker, _noRetweets.Add, id => this.OnAccountDataUpdated(id, true, RelationDataChange.NoRetweets)); }