本文整理汇总了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;
}