当前位置: 首页>>代码示例>>C#>>正文


C# Thread.ChildComments方法代码示例

本文整理汇总了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;
		}
开发者ID:davelondon,项目名称:dontstayin,代码行数:44,代码来源:Service.asmx.cs

示例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");
		}
开发者ID:davelondon,项目名称:dontstayin,代码行数:21,代码来源:Service.asmx.cs


注:本文中的Thread.ChildComments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。