本文整理汇总了C#中Post.CreateUpdateNonce方法的典型用法代码示例。如果您正苦于以下问题:C# Post.CreateUpdateNonce方法的具体用法?C# Post.CreateUpdateNonce怎么用?C# Post.CreateUpdateNonce使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Post
的用法示例。
在下文中一共展示了Post.CreateUpdateNonce方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public async Task Execute()
{
Category<ObjectId> category = SelectCategory();
if (category == null)
{
_logger.Error(InnerMessages.CategoryMissing);
return;
}
List<Post<ObjectId>> posts = new List<Post<ObjectId>>();
List<PostEssentials> postEssencials = ContentProvider.GetPosts(_settings.PostContentPath);
foreach (PostEssentials item in postEssencials)
{
if (item.ShortContent == null)
{
item.ShortContent =
ContentMinifier.Minify(item.FullContent, 250, ContentMinifyMode.ToClosestDot);
}
var post = new Post<ObjectId>()
{
ContentID = ObjectId.GenerateNewId(),
CategoryID = _settings.CategoryID,
AuthorID = _settings.Author.ID,
AuthorName = _settings.Author.Name,
Title = item.Title,
Url = Translit.RussianToTranslitUrl(item.Title),
CommentsCount = 0,
ViewsCount = 0,
FullContent = item.FullContent,
ShortContent = item.ShortContent,
HasImage = true,
IsPublished = true,
AddTimeUtc = DateTime.UtcNow,
PublishTimeUtc = DateTime.UtcNow,
IsIndexed = false
};
post.CreateUpdateNonce();
posts.Add(post);
if (item.ImageFile != null)
{
using (Stream file = item.ImageFile.OpenRead())
{
PipelineResult imageResult = await _previewQueries.CreateStaticImage(file, post.Url);
}
}
await UploadContentImages(post);
}
var insertOptions = new InsertManyOptions() { IsOrdered = false };
await _context.Posts.InsertManyAsync(posts, insertOptions);
}
示例2: CreatePost
//generators
private ContentBase<ObjectId> CreatePost(GenerationContext context)
{
int postIndex = context.TotalEntityCounter % _posts.Count;
int listIteration = context.TotalEntityCounter / _posts.Count;
string title = listIteration + " " + _posts[postIndex].Title;
string url = Translit.RussianToTranslitUrl(title);
DateTime publishTime = DateTime.UtcNow.AddDays(-1).AddMinutes(context.TotalEntityCounter);
UserEssentials user = RandomHelper.PickFromList(_users);
if (_settings.CreatePreviewImages)
{
CreatePostPreviewImage(url, _posts[postIndex].ImageFile);
}
if(_posts[postIndex].ShortContent == null)
{
_posts[postIndex].ShortContent =
ContentMinifier.Minify(_posts[postIndex].FullContent, 250, ContentMinifyMode.ToClosestDot);
}
var post = new Post<ObjectId>()
{
ContentID = ObjectId.GenerateNewId(),
CategoryID = _settings.CategoryID,
AuthorID = user.ID,
AuthorName = user.Name,
Title = title,
Url = url,
CommentsCount = _commentsPerPostCount,
ViewsCount = 0,
FullContent = _posts[postIndex].FullContent,
ShortContent = _posts[postIndex].ShortContent,
HasImage = true,
IsPublished = true,
AddTimeUtc = publishTime,
PublishTimeUtc = publishTime,
IsIndexed = _settings.MarkAsIndexedInSearch
};
post.CreateUpdateNonce();
return post;
}