/// <summary> /// Loads post's comments /// </summary> /// <param name="options"><see cref="LinkedInGetGroupPostCommentsOptions"/> object representing comments retrieval options</param> /// <returns>Request result</returns> /// <remarks>This is synchronous operation, i.e. the current thread will be suspended until it finishes to load all comments. If you want to load post's comments asynchronously, consider to use <see cref="LinkedInClient.GetPostComments"/> function instead</remarks> public LinkedInResponse <bool> LoadComments(LinkedInGetGroupPostCommentsOptions options) { try { if (_Comments == null) { _Comments = new List <LinkedInGroupComment>(); } else { _Comments.Clear(); } options.PostId = Id; _Comments.AddRange(RequestRunner.GetPostComments(options)); return(new LinkedInResponse <bool>(true, LinkedInResponseStatus.OK, null)); } catch (WebException wex) { return(Utils.GetResponse(false, wex, null)); } catch (Exception ex) { return(new LinkedInResponse <bool>(false, LinkedInResponseStatus.OtherException, null, ex)); } }
internal static string PrepareGroupPostCommentFields(LinkedInGetGroupPostCommentsOptions options) { var sb = new StringBuilder(); var gc = options.CommentOptions; if (!gc.HasValues) { return(sb.ToString()); } sb.Append(":("); if (gc[LinkedInGroupPostCommentFields.Id]) { sb.Append("id,"); } if (gc[LinkedInGroupPostCommentFields.Text]) { sb.Append("text,"); } if (gc[LinkedInGroupPostCommentFields.Creator]) { sb.Append("creator,"); } if (gc[LinkedInGroupPostCommentFields.CreationTime]) { sb.Append("creation-timestamp,"); } if (gc[LinkedInGroupPostCommentFields.RelationToViewer]) { sb.Append("relation-to-viewer,"); } sb.Length -= 1; sb.Append(")"); return(sb.ToString()); }
protected async void LoadCommentsForPost(TreeNode node, LinkedInGroupPost post) { LinkedInGetGroupPostCommentsOptions options = new LinkedInGetGroupPostCommentsOptions(); options.CommentOptions.SelectAll(); options.PostId = post.Id; ShowLoading(node); await Task.Run(() => post.LoadComments(options)); ShowGroupPostComments(node, post); node.ExpandAll(); }
protected async void GetComments(string postId) { LinkedInGroupPost post = posts[postId]; LinkedInGroup group = postGroup[post.Id]; LinkedInGetGroupPostCommentsOptions commentOptions = new LinkedInGetGroupPostCommentsOptions(); commentOptions.CommentOptions.SelectAll(); commentOptions.PostId = post.Id; await Task.Run(() => post.LoadComments(commentOptions)); foreach (LinkedInGroupComment comment in post.Comments) { CreateCarrier("LinkedInComment", signal => { signal.LinkedInGroup.Name.Text.Value = group.Name; signal.LinkedInGroup.Id = group.Id; signal.LinkedInPost.Title.Text.Value = post.Title; signal.LinkedInPost.Id = post.Id; signal.CreationTime = comment.CreationTime; signal.Comment = comment.Text; signal.LinkedInCommentCreator.PersonName.Name.Text.Value = comment.Creator.FirstName + " " + comment.Creator.LastName; }); } }