Beispiel #1
0
        public ReadOnlyCollection <Comment> GetComments(
            long ownerId,
            long postId,
            out int totalCount,
            CommentsSort sort = null,
            bool needLikes    = false,
            int?count         = null,
            int?offset        = null,
            int previewLength = 0)
        {
            VkErrors.ThrowIfNumberIsNegative(() => postId);
            VkErrors.ThrowIfNumberIsNegative(() => offset);
            VkErrors.ThrowIfNumberIsNegative(() => count);
            VkErrors.ThrowIfNumberIsNegative(() => previewLength);

            var parameters = new VkParameters
            {
                { "owner_id", ownerId },
                { "post_id", postId },
                { "need_likes", needLikes },
                { "count", count },
                { "offset", offset },
                { "preview_length", previewLength },
                { "sort", sort }
            };

            var response = _vk.Call("wall.getComments", parameters);

            totalCount = response["count"];

            return(response["items"].ToReadOnlyCollectionOf <Comment>(c => c));
        }
Beispiel #2
0
        public void ToString_Desc()
        {
            CommentsSort sort = CommentsSort.Desc;

            string type = sort.ToString();

            type.ShouldEqual("desc");
        }
Beispiel #3
0
 public void CommentsSortTest()
 {
     // get test
     Assert.That(CommentsSort.Asc.ToString(), Is.EqualTo("asc"));
     Assert.That(CommentsSort.Desc.ToString(), Is.EqualTo("desc"));
     // parse test
     Assert.That(CommentsSort.FromJsonString("asc"), Is.EqualTo(CommentsSort.Asc));
     Assert.That(CommentsSort.FromJsonString("desc"), Is.EqualTo(CommentsSort.Desc));
 }
Beispiel #4
0
        public void CommentsSortTest()
        {
            // get test
            Assert.That(actual: CommentsSort.Asc.ToString(), expression: Is.EqualTo(expected: "asc"));
            Assert.That(actual: CommentsSort.Desc.ToString(), expression: Is.EqualTo(expected: "desc"));

            // parse test
            Assert.That(actual: CommentsSort.FromJsonString(response: "asc"), expression: Is.EqualTo(expected: CommentsSort.Asc));
            Assert.That(actual: CommentsSort.FromJsonString(response: "desc"), expression: Is.EqualTo(expected: CommentsSort.Desc));
        }
        public ReadOnlyCollection<Comment> GetAllComments(
            long ownerId,
            long postId,
            CommentsSort sort = null,
            bool needLikes = false,
            int previewLength = 0)
        {
            const int count = 100;
            var i = 0;
            var allComments = new List<Comment>();

            do
            {
                int totalCount;
                var currentComments = _wall.GetComments(ownerId, postId, out totalCount, sort, needLikes, count, i * count, previewLength);
                if (currentComments != null) allComments.AddRange(currentComments);
            } while (++i * count < (_vk.CountFromLastResponse ?? 0));

            return allComments.ToReadOnlyCollection();
        }
Beispiel #6
0
        public ReadOnlyCollection <Comment> GetComments(
            long ownerId,
            long postId,
            out int totalCount,
            CommentsSort sort = null,
            bool needLikes    = false,
            int?count         = null,
            int?offset        = null,
            int previewLength = 0)
        {
            VkErrors.ThrowIfNumberIsNegative(() => postId);
            VkErrors.ThrowIfNumberIsNegative(() => offset);
            VkErrors.ThrowIfNumberIsNegative(() => count);
            VkErrors.ThrowIfNumberIsNegative(() => previewLength);

            var parameters = new VkParameters
            {
                { "owner_id", ownerId },
                { "post_id", postId },
                { "need_likes", needLikes },
                { "count", count },
                { "offset", offset },
                { "preview_length", previewLength },
                { "v", _vk.ApiVersion }
            };

            if (sort != null)
            {
                parameters.Add("sort", sort.ToString().ToLowerInvariant());
            }

            VkResponseArray response = _vk.Call("wall.getComments", parameters);

            totalCount = response[0];

            return(response.Skip(1).ToReadOnlyCollectionOf <Comment>(c => c));
        }
Beispiel #7
0
        public ReadOnlyCollection<Comment> GetComments(long videoId, long? ownerId = null, bool needLikes = false, int? count = null, int? offset = null, CommentsSort sort = null)
        {
            VkErrors.ThrowIfNumberIsNegative(() => videoId);
            VkErrors.ThrowIfNumberIsNegative(() => count);
            VkErrors.ThrowIfNumberIsNegative(() => offset);

            var parameters = new VkParameters
                {
                    {"video_id", videoId},
                    {"owner_id", ownerId},
                    {"need_likes", needLikes},
                    {"count", count},
                    {"offset", offset},
                    {"sort", sort}
                };

            var response = _vk.Call("video.getComments", parameters);

            return response.ToReadOnlyCollectionOf<Comment>(x => x);
        }
Beispiel #8
0
		public ReadOnlyCollection<Comment> GetComments(long videoId, long? ownerId = null, bool needLikes = false, int? count = null, int? offset = null, CommentsSort sort = null)
        {
			var parameters = new VideoGetCommentsParams
			{
				VideoId = videoId,
				OwnerId = ownerId,
				NeedLikes = needLikes,
				Count = count,
				Offset = offset,
				Sort = sort
			};
            return GetComments( parameters);
        }
Beispiel #9
0
        public ReadOnlyCollection<Comment> GetComments(
            long ownerId,
            long postId,
            out int totalCount,
            CommentsSort sort = null,
            bool needLikes = false,
            int? count = null,
            int? offset = null,
            int previewLength = 0)
        {
            VkErrors.ThrowIfNumberIsNegative(() => postId);
            VkErrors.ThrowIfNumberIsNegative(() => offset);
            VkErrors.ThrowIfNumberIsNegative(() => count);
            VkErrors.ThrowIfNumberIsNegative(() => previewLength);

            var parameters = new VkParameters
                             {
                                 { "owner_id", ownerId },
                                 { "post_id", postId },
                                 { "need_likes", needLikes },
                                 { "count", count },
                                 { "offset", offset },
                                 { "preview_length", previewLength },
                                 { "sort", sort }
                             };

            var response = _vk.Call("wall.getComments", parameters);

            totalCount = response["count"];

            return response["items"].ToReadOnlyCollectionOf<Comment>(c => c);
        }
Beispiel #10
0
        public ReadOnlyCollection<Comment> GetComments(long photoId, long? ownerId = null, bool? needLikes = null, int? count = null, int? offset = null, CommentsSort sort = null, string accessKey = null)
        {
            VkErrors.ThrowIfNumberIsNegative(() => photoId);
            VkErrors.ThrowIfNumberIsNegative(() => offset);
            VkErrors.ThrowIfNumberIsNegative(() => count);

            var parameters = new VkParameters
                {
                    {"owner_id", ownerId},
                    {"photo_id", photoId},
                    {"need_likes", needLikes},
                    {"offset", offset},
                    {"count", count},
                    {"sort", sort},
                    {"access_key", accessKey}
                };

            VkResponseArray response = _vk.Call("photos.getComments", parameters);

            return response.ToReadOnlyCollectionOf<Comment>(x => x);
        }
Beispiel #11
0
        public ReadOnlyCollection<Comment> GetComments(
            long ownerId,
            long postId,
            out int totalCount,
            CommentsSort sort = null,
            bool needLikes = false,
            int? count = null,
            int? offset = null,
            int previewLength = 0)
        {
            VkErrors.ThrowIfNumberIsNegative(() => postId);
            VkErrors.ThrowIfNumberIsNegative(() => offset);
            VkErrors.ThrowIfNumberIsNegative(() => count);
            VkErrors.ThrowIfNumberIsNegative(() => previewLength);

            var parameters = new VkParameters
                             {
                                 { "owner_id", ownerId },
                                 { "post_id", postId },
                                 { "need_likes", needLikes },
                                 { "count", count },
                                 { "offset", offset },
                                 { "preview_length", previewLength }
                             };

            if (sort != null)
                parameters.Add("sort", sort.ToString().ToLowerInvariant());

            VkResponseArray response = _vk.Call("wall.getComments", parameters);

            totalCount = response[0];

            return response.Skip(1).ToReadOnlyCollectionOf<Comment>(c => c);
        }
Beispiel #12
0
        public ReadOnlyCollection <Comment> GetComments(long videoId, long?ownerId = null, bool needLikes = false, int?count = null, int?offset = null, CommentsSort sort = null)
        {
            var parameters = new VideoGetCommentsParams
            {
                VideoId   = videoId,
                OwnerId   = ownerId,
                NeedLikes = needLikes,
                Count     = count,
                Offset    = offset,
                Sort      = sort
            };

            return(GetComments(parameters).ToReadOnlyCollection());
        }
Beispiel #13
0
        public ReadOnlyCollection <Comment> GetComments(long videoId, long?ownerId = null, bool needLikes = false, int?count = null, int?offset = null, CommentsSort sort = null)
        {
            VkErrors.ThrowIfNumberIsNegative(() => videoId);
            VkErrors.ThrowIfNumberIsNegative(() => count);
            VkErrors.ThrowIfNumberIsNegative(() => offset);

            var parameters = new VkParameters
            {
                { "video_id", videoId },
                { "owner_id", ownerId },
                { "need_likes", needLikes },
                { "count", count },
                { "offset", offset },
                { "sort", sort }
            };

            var response = _vk.Call("video.getComments", parameters);

            return(response.ToReadOnlyCollectionOf <Comment>(x => x));
        }
        public ReadOnlyCollection<Comment> GetAllComments(long videoId, long? ownerId = null, bool needLikes = false, CommentsSort sort = null)
        {
            const int count = 100;
            var i = 0;
            var result = new List<Comment>();

            do
            {
                var currentItems = _video.GetComments(videoId, ownerId, needLikes, count, i * count, sort);
                if (currentItems != null) result.AddRange(currentItems);
            } while (++i * count < (_vk.CountFromLastResponse ?? 0));

            return result.ToReadOnlyCollection();
        }