本文整理汇总了C#中Thread.ChildComments方法的典型用法代码示例。如果您正苦于以下问题:C# Thread.ChildComments方法的具体用法?C# Thread.ChildComments怎么用?C# Thread.ChildComments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thread
的用法示例。
在下文中一共展示了Thread.ChildComments方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetThreadComments
public CommentResult GetThreadComments(int threadK, int pageNumber, bool getCommentsOnly)
{
Thread thread = new Thread(threadK);
GroupUsr groupUsr = null;
if (Usr.Current != null && thread.Group != null)
{
groupUsr = thread.Group.GetGroupUsr(Usr.Current);
}
ThreadUsr threadUsr = null;
if (Usr.Current != null && thread.CheckPermissionRead(Usr.Current))
{
try
{
threadUsr = new ThreadUsr(thread.K, Usr.Current.K);
}
catch (BobNotFound)
{
}
}
CommentResult result = new CommentResult();
if (pageNumber <= 0)
{
pageNumber = (result.firstUnreadPage > 0) ? result.firstUnreadPage : 1;
}
result.comments = thread.ChildComments().Page(pageNumber, Vars.CommentsPerPage).ConvertAll(c => CreateCommentStub(c, threadUsr, groupUsr)).ToArray();
if (result.comments.Length == 0)
{
throw new Exception("No comments to retrieve.");
}
result.firstUnreadPage = !getCommentsOnly && threadUsr != null && threadUsr.ViewCommentsInUse > 0 ?
(threadUsr.ViewCommentsInUse / Vars.CommentsPerPage) + 1 : 0;
result.lastPage = !getCommentsOnly ? thread.LastPage : 0;
result.currentPage = pageNumber;
result.initialComment = (!getCommentsOnly && pageNumber > 1) ? CreateCommentStub(thread.ChildComments()[0], threadUsr, groupUsr) : null;
result.viewComments = !getCommentsOnly && threadUsr != null ? threadUsr.ViewCommentsInUse : 0;
result.totalComments = !getCommentsOnly ? thread.TotalComments : 0;
return result;
}
示例2: CreateReply
public CommentStub[] CreateReply(int discussableObjectType, int discussableObjectK, int threadK, string duplicateGuid, string rawCommentHtml, bool formatting, int lastKnownCommentK, string[] inviteUsrOptions)
{
Thread thread = new Thread(threadK);
Comment.MakerReturn makerReturn = Thread.CreateReply(thread, new Guid(duplicateGuid),
Comment.ParseCommentHtml(rawCommentHtml, formatting, true), GetUsrKsFromOptions(inviteUsrOptions).ToList());
if (makerReturn.Success)
{
IDiscussable discussable = Bob.Get((Model.Entities.ObjectType)discussableObjectType, discussableObjectK) as IDiscussable;
if (discussable != null)
{
discussable.UpdateTotalComments(null);
}
return thread.ChildComments().Page(thread.LastPage, Vars.CommentsPerPage).ToList().Where(c => c.K > lastKnownCommentK).ToList()
.ConvertAll(c => CreateCommentStub(c, thread.GetThreadUsr(Usr.Current), null)).ToArray();
}
else if (makerReturn.Duplicate)
return null;
else throw new Exception("Error");
}