本文整理汇总了C#中IContent.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# IContent.GetValue方法的具体用法?C# IContent.GetValue怎么用?C# IContent.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContent
的用法示例。
在下文中一共展示了IContent.GetValue方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFormModel
public static FormModel GetFormModel(IContent document)
{
if (document == null)
{
return null;
}
var property = GetFormModelProperty(document.ContentType);
if (property == null)
{
return null;
}
var json = document.GetValue(property.Alias) as string;
if (string.IsNullOrEmpty(json))
{
return null;
}
return SerializationHelper.DeserializeFormModel(json);
}
示例2: GetObjectByPage
public static CanvasModel GetObjectByPage(IContent node)
{
try
{
string json = node.GetValue<string>("canvas");
var model = new CanvasModel();
if (!string.IsNullOrEmpty(json))
{
model = JsonConvert.DeserializeObject<CanvasModel>(json);
}
return model;
}
catch (Exception ex)
{
Log.Error("Canvas error on GetObjectByPage in Repository.", ex);
return null;
}
}
示例3: FormBulkRemove
private IContent FormBulkRemove(IContent form, BulkUpdateModel model)
{
if (model.Tags != null)
{
form.RemoveTags("formTags", model.Tags, TAG_GROUP_GLEANER_FORM);
}
if (model.Groups != null)
{
var currentValue = form.GetValue<string>("associatedGroups").ToDelimitedList().Select(Int32.Parse);
form.SetValue("associatedGroups", string.Join(",", currentValue.Except(model.Groups)));
}
return form;
}
示例4: GetFormVersionItem
private FormVersionListItemDisplay GetFormVersionItem(IContent content)
{
var glVersion = content.GetValue<string>("glVersion") ?? string.Empty;
var formUpload = content.GetValue<string>("formUpload");
var files = string.IsNullOrEmpty(formUpload)
? new List<KeyValuePair<string, string>>()
: formUpload.ToDelimitedList()
.Where(x => !string.IsNullOrEmpty(x))
.Select(path => new KeyValuePair<string, string>(path, Path.GetFileName(path)))
.ToList();
var item = new FormVersionListItemDisplay
{
Files = files,
GlVersion = glVersion,
UpdateDate = content.UpdateDate,
Updater = Mapper.Map<IProfile, UserBasic>(Services.UserService.GetProfileById(content.WriterId)),
VersionType = glVersion.Contains(".") ? "Update" : (glVersion.Equals("1") ? "New Version" : "New Document")
};
return item;
}
示例5: FromContent
private object FromContent(IContent post)
{
return new MetaWeblogPost
{
AllowComments = post.GetValue<bool>("enableComments") ? 1 : 2,
Author = post.GetValue<string>("author"),
Categories = post.GetValue<string>("categories").Split(new[]{','}, StringSplitOptions.RemoveEmptyEntries),
Content = post.ContentType.Alias == "ArticulateRichText"
? post.GetValue<string>("richText")
: new MarkdownDeep.Markdown().Transform(post.GetValue<string>("markdown")),
CreateDate = post.UpdateDate,
Id = post.Id.ToString(CultureInfo.InvariantCulture),
Slug = post.GetValue<string>("umbracoUrlName").IsNullOrWhiteSpace()
? post.Name.ToUrlSegment()
: post.GetValue<string>("umbracoUrlName").ToUrlSegment(),
Excerpt = post.GetValue<string>("excerpt"),
Tags = string.Join(",",post.GetValue<string>("tags").Split(new[]{','}, StringSplitOptions.RemoveEmptyEntries)),
Title = post.Name
};
}
示例6: EnsureNavigationTitle
/// <summary>
/// Ensures that the node name is the same as the post title
/// </summary>
/// <param name="doc"></param>
/// <returns></returns>
public IContent EnsureNavigationTitle(IContent doc)
{
var navTitle = doc.GetValue<string>("uBlogsyNavigationTitle");
var title = doc.GetValue<string>("uBlogsyContentTitle");
if (string.IsNullOrEmpty(navTitle) && !string.IsNullOrEmpty(title))
{
navTitle = title;
// ensure node name is same as title
doc.SetValue("uBlogsyNavigationTitle", navTitle);
ApplicationContext.Current.Services.ContentService.Save(doc, 0, false);
}
return doc;
}
示例7: UpdateFormVersion
private void UpdateFormVersion(IContent savingContent)
{
if (!savingContent.IsDirty())
{
return;
}
var glVersion = savingContent.GetValue<string>("glVersion");
var version = "1";
if (!string.IsNullOrEmpty(glVersion))
{
var parts = glVersion.ToDelimitedList(".");
var major = Int32.Parse(parts[0]);
var minor = parts.Count > 1 ? Int32.Parse(parts[1]) : 0;
var isNewVersion = savingContent.IsPropertyDirty("formUpload");
version = isNewVersion
? (major + 1).ToString()
: string.Join(".", major, minor + 1);
}
savingContent.SetValue("glVersion", version);
}
示例8: EnsureCorrectPostTitle
/// <summary>
/// Ensures that the node name is the same as the post title
/// </summary>
/// <param name="doc"></param>
/// <returns></returns>
public IContent EnsureCorrectPostTitle(IContent doc)
{
var title = doc.GetValue<string>("uBlogsyContentTitle");
if (string.IsNullOrEmpty(title))
{
// ensure node name is same as title
doc.SetValue("uBlogsyContentTitle", doc.Name);
ApplicationContext.Current.Services.ContentService.Save(doc, 0, false);
}
return doc;
}
示例9: EnsureCorrectPostNodeName
/// <summary>
/// Ensures that the node name is the same as the post title
/// </summary>
/// <param name="doc"></param>
/// <returns></returns>
public IContent EnsureCorrectPostNodeName(IContent doc)
{
var useTitleAsNodeName = IContentHelper.GetValueFromAncestor(doc, "uBlogsyLanding", "uBlogsyGeneralUseTitleAsNodeName");
if (useTitleAsNodeName == "1")
{
var title = doc.GetValue<string>("uBlogsyContentTitle");
if (!string.IsNullOrEmpty(title) && doc.Name != title)
{
// ensure node name is same as title
doc.Name = title;
ApplicationContext.Current.Services.ContentService.Save(doc, 0, false);
}
}
return doc;
}
示例10: EnsureOthersDontHave
/// <summary>
/// Обеспечивает отсутствие в прочих опубликованных акциях тех товаров, которые включены в текущую.
/// При наличии таковых товары убираются из прочих акций, которые затем перепубликовываются без отработки событий.
/// Внимание! Umbraco HQ выражала намерение убрать возможность публиковать узлы без отработки событий. Это не должно
/// поломать логику метода, но стоит помнить про вероятность такого развития событий при обновлениях CMS.
/// </summary>
/// <param name="promoEventNode"></param>
public static void EnsureOthersDontHave(IContent promoEventNode)
{
var contentService = global::Umbraco.Core.ApplicationContext.Current.Services.ContentService;
var thisPromoProductsIds = promoEventNode.GetValue<string>("products").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => Int32.Parse(x));
var otherPublishedPromos = PromoEvent.Cache.Where(x => x.Node.Id != promoEventNode.Id);
foreach (var otherPublishedPromo in otherPublishedPromos)
{
var otherPromoProductIds = otherPublishedPromo.Products.Select(x => x.Node.Id);
if (thisPromoProductsIds.Intersect(otherPromoProductIds).Any())
{
var newOtherPromoProductIds = String.Join(",", otherPromoProductIds.Except(thisPromoProductsIds));
var otherPromo = contentService.GetById(otherPublishedPromo.Node.Id);
otherPromo.SetValue("products", newOtherPromoProductIds);
contentService.SaveAndPublish(otherPromo, 0, false);
}
}
}
示例11: GetPostAuthorPhotoUrl
private string GetPostAuthorPhotoUrl(IContent post)
{
var authorId = post.GetValue<int>("postAuthor");
var author = Members.GetById(authorId);
string profilePhotoUrl = null;
if (author != null)
{
var profilePhoto = Umbraco.TypedMedia(author.GetPropertyValue<int>("photo"));
if (profilePhoto != null)
{
profilePhotoUrl = profilePhoto.Url;
}
}
if (String.IsNullOrEmpty(profilePhotoUrl))
{
profilePhotoUrl = "http://www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&f=y"; // the gray man...
}
return profilePhotoUrl;
}
示例12: GetPostAuthorFullName
private string GetPostAuthorFullName(IContent post)
{
string memberFullName = null;
var authorId = post.GetValue<int>("postAuthor");
var author = Members.GetById(authorId);
if (author != null)
{
memberFullName = String.Format("{0} {1}", author.GetPropertyValue<String>("arborFirstName"), author.GetPropertyValue<String>("arborLastName")).Trim();
if (String.IsNullOrEmpty(memberFullName))
{
memberFullName = String.Format("{0} {1}", author.GetPropertyValue<String>("firstName"), author.GetPropertyValue<String>("lastName")).Trim();
}
if (String.IsNullOrEmpty(memberFullName))
{
memberFullName = author.Name;
}
}
if (String.IsNullOrEmpty(memberFullName))
{
memberFullName = "Not Available";
}
return memberFullName;
}