本文整理汇总了C#中IContent.SetTags方法的典型用法代码示例。如果您正苦于以下问题:C# IContent.SetTags方法的具体用法?C# IContent.SetTags怎么用?C# IContent.SetTags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContent
的用法示例。
在下文中一共展示了IContent.SetTags方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FormBulkUpdate
private IContent FormBulkUpdate(IContent form, BulkUpdateModel model)
{
if (model.Tags != null)
{
form.SetTags("formTags", model.Tags, true, TAG_GROUP_GLEANER_FORM);
}
if (model.Groups != null)
{
form.SetValue("associatedGroups", string.Join(",", model.Groups));
}
if (model.IsPublic.HasValue)
{
form.SetValue("isPublic", model.IsPublic.Value);
}
if (model.IsRequired.HasValue)
{
form.SetValue("isRequired", model.IsRequired.Value);
}
if (model.StartDate.HasValue)
{
form.SetValue("startDate", model.StartDate.Value);
}
if (model.EndDate.HasValue)
{
form.SetValue("endDate", model.EndDate.Value);
}
return form;
}
示例2: FormBulkAdd
private IContent FormBulkAdd(IContent form, BulkUpdateModel model)
{
if (model.Tags != null)
{
form.SetTags("formTags", model.Tags, false, TAG_GROUP_GLEANER_FORM);
}
if (model.Groups != null)
{
var currentValue = form.GetValue<string>("associatedGroups").ToDelimitedList().Select(Int32.Parse);
form.SetValue("associatedGroups", string.Join(",", currentValue.Union(model.Groups)));
}
return form;
}
示例3: AddOrUpdateContent
private void AddOrUpdateContent(IContent content, MetaWeblogPost post, IUser user, bool publish)
{
content.Name = post.Title;
content.SetValue("author", user.Name);
if (content.HasProperty("richText"))
{
content.SetValue("richText", post.Content);
}
if (!post.Slug.IsNullOrWhiteSpace())
{
content.SetValue("umbracoUrlName", post.Slug);
}
if (!post.Excerpt.IsNullOrWhiteSpace())
{
content.SetValue("excerpt", post.Excerpt);
}
if (post.AllowComments == 1)
{
content.SetValue("enableComments", 1);
}
else if (post.AllowComments == 2)
{
content.SetValue("enableComments", 0);
}
content.SetTags("categories", post.Categories, true, "ArticulateCategories");
var tags = post.Tags.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).Distinct().ToArray();
content.SetTags("tags", tags, true, "ArticulateTags");
if (publish)
{
if (post.CreateDate != DateTime.MinValue)
{
content.SetValue("publishedDate", post.CreateDate);
}
_applicationContext.Services.ContentService.SaveAndPublishWithStatus(content, user.Id);
}
else
{
_applicationContext.Services.ContentService.Save(content, user.Id);
}
}
示例4: AddOrUpdateContent
private void AddOrUpdateContent(IContent content, MetaWeblogPost post, IUser user, bool publish, bool extractFirstImageAsProperty)
{
content.Name = post.Title;
content.SetValue("author", user.Name);
if (content.HasProperty("richText"))
{
var firstImage = "";
//we need to replace all absolute image paths with relative ones
var contentToSave = _mediaSrc.Replace(post.Content, match =>
{
if (match.Groups.Count == 2)
{
var imageSrc = match.Groups[1].Value.EnsureStartsWith('/');
if (firstImage.IsNullOrWhiteSpace())
{
firstImage = imageSrc;
}
return " src=\"" + imageSrc + "\"";
}
return null;
});
var imagesProcessed = 0;
//now replace all absolute anchor paths with relative ones
contentToSave = _mediaHref.Replace(contentToSave, match =>
{
if (match.Groups.Count == 2)
{
var href = " href=\"" +
match.Groups[1].Value.EnsureStartsWith('/') +
"\" class=\"a-image-" + imagesProcessed + "\" ";
imagesProcessed++;
return href;
}
return null;
});
content.SetValue("richText", contentToSave);
if (extractFirstImageAsProperty
&& content.HasProperty("postImage")
&& !firstImage.IsNullOrWhiteSpace())
{
content.SetValue("postImage", firstImage);
//content.SetValue("postImage", JsonConvert.SerializeObject(JObject.FromObject(new
//{
// src = firstImage
//})));
}
}
if (!post.Slug.IsNullOrWhiteSpace())
{
content.SetValue("umbracoUrlName", post.Slug);
}
if (!post.Excerpt.IsNullOrWhiteSpace())
{
content.SetValue("excerpt", post.Excerpt);
}
if (post.AllowComments == 1)
{
content.SetValue("enableComments", 1);
}
else if (post.AllowComments == 2)
{
content.SetValue("enableComments", 0);
}
content.SetTags("categories", post.Categories, true, "ArticulateCategories");
var tags = post.Tags.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Distinct().ToArray();
content.SetTags("tags", tags, true, "ArticulateTags");
if (publish)
{
if (post.CreateDate != DateTime.MinValue)
{
content.SetValue("publishedDate", post.CreateDate);
}
_applicationContext.Services.ContentService.SaveAndPublishWithStatus(content, user.Id);
}
else
{
_applicationContext.Services.ContentService.Save(content, user.Id);
}
}