本文整理汇总了C#中IContent.HasProperty方法的典型用法代码示例。如果您正苦于以下问题:C# IContent.HasProperty方法的具体用法?C# IContent.HasProperty怎么用?C# IContent.HasProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContent
的用法示例。
在下文中一共展示了IContent.HasProperty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToDocument
public void ToDocument(IContent document)
{
document.Id = Id;
document.Name = Name;
document.ParentId = ParentId;
foreach (var property in Properties)
{
if (document.HasProperty(property.Alias))
{
document.Properties[property.Alias].Value = property.Value;
}
}
}
示例2: 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);
}
}
示例3: SetProperty
private static void SetProperty(IContent orderedProductDoc, string propertyAlias, object value)
{
if (orderedProductDoc.HasProperty(propertyAlias))
orderedProductDoc.SetValue(propertyAlias, value);
}
示例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);
}
}
示例5: SetContentValue
public void SetContentValue(IContent content, string name, string value)
{
if (content.HasProperty(name))
{
content.SetValue(name, value);
}
}