public ActivityInfo(PlatformClient client, ActivityData data) : base(client) { _data = data; _postUser = data.Owner != null ? client.People.InternalGetAndUpdateProfile(data.Owner) : null; _attachedContent = data.AttachedContent != null ? AttachedContentDecorator(data.AttachedContent, client) : null; _comments = _data.Comments != null ? _data.Comments.Select(dt => new CommentInfo(Client, dt, _data, this)).ToArray() : null; }
//ActivityInfo初期化はこちらの特殊仕様を使う。 //これはActivityInfo用のCommentInfo、CommentInfo用のActivityInfoという無限ループ回避用処置 internal CommentInfo( PlatformClient client, CommentData commentData, ActivityData activityData, ActivityInfo activityInfo) : base(client) { _commentData = commentData; _activityData = activityData; _owner = commentData.Owner != null ? client.People.InternalGetAndUpdateProfile(commentData.Owner) : null; _parentActivity = activityInfo; _talkgadgetBindObjs = new Dictionary<EventHandler, IDisposable>(); }
public InitData(string atValue, string pvtValue, string ejxValue, string buildLevel, string lang, string afsid, CircleData[] circleInfos, ActivityData[] latestActivities) { AtValue = atValue; PvtValue = pvtValue; EjxValue = ejxValue; BuildLevel = buildLevel; Lang = lang; Afsid = afsid; CircleInfos = circleInfos; LatestActivities = latestActivities; }
public ImageData(ImageUpdateApiFlag loadedApiType, string id, string name = null, int? width = null, int? height = null, string imageUrl = null, Uri linkUrl = null, DateTime? createDate = null, ImageTagData[] attachedTags = null, ProfileData owner = null, ActivityData isolateActivity = null) { LoadedApiTypes = loadedApiType; Id = id; Name = name; Width = width; Height = height; ImageUrl = imageUrl; LinkUrl = linkUrl; CreateDate = createDate; AttachedTags = attachedTags; Owner = owner; IsolateActivity = isolateActivity; }
public Task UpdateGetActivityAsync(bool isForced, ActivityUpdateApiFlag updaterTypes) { var cache = Client.Activity.InternalGetActivityCache(_data.Id); return cache.SyncerUpdateActivity.LockAsync( isForced, () => _data.PostStatus != PostStatusType.Removed && (LoadedApiTypes & updaterTypes) != updaterTypes, async () => { try { var nwData = Client.Activity.InternalUpdateActivity(await Client.ServiceApi.GetActivityAsync(Id, Client)); if (_data.Comments != null) { var nwComments = from newComments in nwData.Comments join oldComments in _data.Comments on newComments.CommentId equals oldComments.CommentId into c from d in c.DefaultIfEmpty() where d == null select newComments; var rmComments = from oldComments in _data.Comments join newComments in nwData.Comments on oldComments.CommentId equals newComments.CommentId into c from d in c.DefaultIfEmpty() where d == null select new CommentData( oldComments.CommentId, oldComments.ActivityId, oldComments.Html, oldComments.PostDate, oldComments.EditDate, oldComments.Owner, PostStatusType.Removed); foreach (var item in nwComments.Concat(rmComments)) Client.Activity.InternalSendObjectToStream(item); } else foreach (var item in nwData.Comments) Client.Activity.InternalSendObjectToStream(item); _data = nwData; _postUser = Client.People.InternalGetAndUpdateProfile(_data.Owner); _attachedContent = _data.AttachedContent != null ? AttachedContentDecorator(_data.AttachedContent, Client) : null; _comments = _data.Comments.Select(dt => new CommentInfo(Client, dt, _data, this)).ToArray(); } catch (ApiErrorException e) { if (e.InnerException is System.Net.WebException && ((System.Net.WebException)e.InnerException).Status == System.Net.WebExceptionStatus.UnknownError) Client.Activity.InternalUpdateActivity(new ActivityData(Id, status: PostStatusType.Removed, updaterTypes: ActivityUpdateApiFlag.GetActivity)); else throw new FailToOperationException<ActivityInfo>("UpdateGetActivityAsync()に失敗しました。", this, e); } }, () => { _data = cache.Value; _postUser = Client.People.InternalGetAndUpdateProfile(_data.Owner); _attachedContent = _data.AttachedContent != null ? AttachedContentDecorator(_data.AttachedContent, Client) : null; if (_data.Comments != null) _comments = _data.Comments.Select(dt => new CommentInfo(Client, dt, _data, this)).ToArray(); }); }