本文整理汇总了C#中Post.SetCustomProperties方法的典型用法代码示例。如果您正苦于以下问题:C# Post.SetCustomProperties方法的具体用法?C# Post.SetCustomProperties怎么用?C# Post.SetCustomProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Post
的用法示例。
在下文中一共展示了Post.SetCustomProperties方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
protected Post Create(Topic topic, Post post, String subject, String message, IDictionary<String, Object> customProperties) {
if (topic == null) {
throw new ArgumentNullException("topic");
}
if (String.IsNullOrWhiteSpace(subject)) {
throw new ArgumentNullException("subject");
}
if (String.IsNullOrWhiteSpace(message)) {
throw new ArgumentNullException("message");
}
// Let's get the topic from the data-storage!
topic = this.topicRepo.Read(t => t.Id == topic.Id);
if (topic == null) {
throw new ArgumentException("topic does not exist");
}
if (post != null) {
// Let's get the topic from the data-storage!
post = this.postRepo.Read(po => po.Id == post.Id);
if (post == null) {
throw new ArgumentException("post does not exist");
}
}
this.logger.WriteFormat("Create called on PostService, subject: {0}, topic id: {1}", subject, topic.Id);
AccessFlag flag = this.permService.GetAccessFlag(this.userProvider.CurrentUser, topic.Forum);
if ((flag & AccessFlag.Reply) != AccessFlag.Reply) {
this.logger.WriteFormat("User does not have permissions to create a new post in topic {1}, subject: {0}", subject, topic.Id);
throw new PermissionException("post, create");
}
Post p = new Post {
Author = this.userProvider.CurrentUser,
AuthorId = this.userProvider.CurrentUser.Id,
Changed = DateTime.UtcNow,
Created = DateTime.UtcNow,
Editor = this.userProvider.CurrentUser,
EditorId = this.userProvider.CurrentUser.Id,
Topic = topic,
TopicId = topic.Id,
Forum = topic.Forum,
ForumId = topic.ForumId,
Message = message,
State = PostState.None,
Subject = subject
};
p.SetCustomProperties(customProperties);
// Was a parent post given?
if (post != null) {
// Let's store that then, for the "tree" view (and other features)
p.ParentPost = post;
p.ParentPostId = post.Id;
}
this.postRepo.Create(p);
this.logger.WriteFormat("Post created in PostService, Id: {0}", p.Id);
this.eventPublisher.Publish<PostCreated>(new PostCreated {
Post = p
});
this.logger.WriteFormat("Create events in PostService fired, Id: {0}", p.Id);
return p;
}