internal ViewModel(string id, FeedDetailModel model) { if (string.IsNullOrEmpty(id)) { throw new ArgumentException(nameof(id)); } Id = id; ReplyProvider = new CoolapkListProvider( (p, page, firstItem, lastItem) => UriHelper.GetUri( UriType.GetFeedReplies, id, replyListType, p < 0 ? ++page : p, page > 1 ? $"&firstItem={firstItem}&lastItem={lastItem}" : string.Empty, isFromAuthor), (a, b) => ((FeedReplyModel)a).Id == b.Value <int>("id"), (o) => new Entity[] { new FeedReplyModel(o) }, MessageType.NoMoreReply, "id"); LikeProvider = new CoolapkListProvider( (p, page, firstItem, lastItem) => UriHelper.GetUri( UriType.GetLikeList, id, p < 0 ? ++page : p, page > 1 ? $"&firstItem={firstItem}&lastItem={lastItem}" : string.Empty), (a, b) => ((UserModel)a).Url == b.Value <string>("url"), (o) => new Entity[] { new UserModel(o) }, MessageType.NoMoreLikeUser, "uid"); ShareProvider = new CoolapkListProvider( (p, page, firstItem, lastItem) => UriHelper.GetUri( UriType.GetShareList, p == -2 ? true : false, id, p < 0 ? ++page : p), (a, b) => ((SourceFeedModel)a).Url == b.Value <string>("url"), (o) => new Entity[] { new SourceFeedModel(o) }, MessageType.NoMoreShare, "id"); HotReplys = model.HotReplies; }
internal ViewModel(string id, FeedDetailModel model) { if (string.IsNullOrEmpty(id)) { throw new ArgumentException(nameof(id)); } Id = id; ReplyProvider = new CoolapkListProvider( async(p, page, firstItem, lastItem) => (JArray)await DataHelper.GetDataAsync( DataUriType.GetFeedReplies, id, replyListType, p == -1 ? ++page : p, page > 1 ? $"&firstItem={firstItem}&lastItem={lastItem}" : string.Empty, isFromAuthor), (a, b) => ((FeedReplyModel)a).Id == b.Value <int>("id"), (o) => new Entity[] { new FeedReplyModel(o) }, () => loader.GetString("noMoreReply"), "id"); LikeProvider = new CoolapkListProvider( async(p, page, firstItem, lastItem) => (JArray)await DataHelper.GetDataAsync( DataUriType.GetLikeList, id, p == -1 ? ++page : p, page > 1 ? $"&firstItem={firstItem}&lastItem={lastItem}" : string.Empty), (a, b) => ((UserModel)a).Url == b.Value <string>("url"), (o) => new Entity[] { new UserModel(o) }, () => loader.GetString("noMoreLikeUser"), "uid"); ShareProvider = new CoolapkListProvider( async(p, page, firstItem, lastItem) => (JArray)await DataHelper.GetDataAsync(DataUriType.GetShareList, id, p == -1 ? ++page : p), (a, b) => ((SourceFeedModel)a).Url == b.Value <string>("url"), (o) => new Entity[] { new SourceFeedModel(o) }, () => loader.GetString("noMoreShare"), "id"); HotReplys = model.HotReplies; }