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


C# Forum.SetCustomProperties方法代码示例

本文整理汇总了C#中Forum.SetCustomProperties方法的典型用法代码示例。如果您正苦于以下问题:C# Forum.SetCustomProperties方法的具体用法?C# Forum.SetCustomProperties怎么用?C# Forum.SetCustomProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Forum的用法示例。


在下文中一共展示了Forum.SetCustomProperties方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create

		/// <summary>
		/// Method for creating a new forum.
		/// </summary>
		/// <param name="category">The parent category of the forum.</param>
		/// <param name="parentForum">The (optional) parent forum of the forum.</param>
		/// <param name="name">The name of the forum.</param>
		/// <param name="description">The description of the forum.</param>
		/// <param name="sortOrder">The sort order/placement of the forum.</param>
		/// <param name="customProperties"></param>
		/// <returns>The newly created forum.</returns>
		/// <exception cref="System.ArgumentNullException">If the provided category is null.</exception>
		public Forum Create(Category category, Forum parentForum, String name, String description, Int32 sortOrder, IDictionary<String, Object> customProperties = null) {
			if (category == null) {
				throw new ArgumentNullException("category");
			}
			category = this.categoryRepo.Read(c => c.Id == category.Id);
			if (category == null) {
				throw new ArgumentException("category does not exist");
			}

			this.logger.WriteFormat("Create called on ForumService, Name: {0}, Description: {1}, Sort Order: {2}, category id: {3}", name, description, sortOrder, category.Id);
			if (!this.permService.CanCreateForum(this.userProvider.CurrentUser, category)) {
				this.logger.WriteFormat("User does not have permissions to create a new forum in category {1}, name: {0}", name, category.Id);
				throw new PermissionException("forum, create");
			}

			Forum f = new Forum {
				Name = name,
				SortOrder = sortOrder,
				Description = description,
				CategoryId = category.Id
			};
			f.SetCustomProperties(customProperties);

			if (parentForum != null) {
				parentForum = this.forumRepo.Read(fo => fo.Id == parentForum.Id);
				if (parentForum == null) {
					throw new ArgumentException("parentForum does not exist");
				}
				f.ParentForumId = parentForum.Id;
			}

			this.forumRepo.Create(f);
			this.logger.WriteFormat("Forum created in ForumService, Id: {0}", f.Id);
			this.eventPublisher.Publish<ForumCreated>(new ForumCreated {
				Forum = f
			});
			this.logger.WriteFormat("Create events in ForumService fired, Id: {0}", f.Id);

			return f;
		}
开发者ID:razzles67,项目名称:NForum,代码行数:51,代码来源:ForumService.cs


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