本文整理汇总了C#中Topic.SetCustomProperties方法的典型用法代码示例。如果您正苦于以下问题:C# Topic.SetCustomProperties方法的具体用法?C# Topic.SetCustomProperties怎么用?C# Topic.SetCustomProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Topic
的用法示例。
在下文中一共展示了Topic.SetCustomProperties方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
/// <summary>
/// Method for creating a new topic.
/// </summary>
/// <param name="forum">The parent forum of the topic.</param>
/// <param name="subject">The subject of the topic.</param>
/// <param name="message">The content/message of the topic.</param>
/// <param name="type">The type of the topic </param>
/// <param name="customPropties"></param>
/// <returns>The newly created topic.</returns>
public Topic Create(Forum forum, String subject, String message, TopicType type, IDictionary<String, Object> customPropties = null) {
if (forum == null) {
throw new ArgumentNullException("forum");
}
if (String.IsNullOrWhiteSpace(subject)) {
throw new ArgumentNullException("subject");
}
if (String.IsNullOrWhiteSpace(message)) {
throw new ArgumentNullException("message");
}
forum = this.forumRepo.Read(f => f.Id == forum.Id);
if (forum == null) {
throw new ArgumentException("forum does not exist");
}
this.logger.WriteFormat("Create called on TopicService, subject: {0}, forum id: {1}", subject, forum.Id);
AccessFlag flag = this.permService.GetAccessFlag(this.userProvider.CurrentUser, forum);
if ((flag & AccessFlag.Create) != AccessFlag.Create) {
this.logger.WriteFormat("User does not have permissions to create a new topic in forum {1}, subject: {0}", subject, forum.Id);
throw new PermissionException("topic, create");
}
if (type != TopicType.Regular && (flag & AccessFlag.Priority) != AccessFlag.Priority) {
this.logger.WriteFormat("User does not have permissions to set topic type on new topic in forum {1}, subject: {0}", subject, forum.Id);
throw new PermissionException("topic, type");
}
Topic t = new Topic {
Author = this.userProvider.CurrentUser,
AuthorId = this.userProvider.CurrentUser.Id,
Changed = DateTime.UtcNow,
Created = DateTime.UtcNow,
Editor = this.userProvider.CurrentUser,
EditorId = this.userProvider.CurrentUser.Id,
Forum = forum,
ForumId = forum.Id,
Message = message,
State = TopicState.None,
Subject = subject,
Type = type
};
t.SetCustomProperties(customPropties);
this.topicRepo.Create(t);
this.logger.WriteFormat("Topic created in TopicService, Id: {0}", t.Id);
this.eventPublisher.Publish<TopicCreated>(new TopicCreated {
Topic = t
});
this.logger.WriteFormat("Create events in TopicService fired, Id: {0}", t.Id);
return t;
}