本文整理汇总了C#中Orchard.ContentManagement.ContentItem.Has方法的典型用法代码示例。如果您正苦于以下问题:C# ContentItem.Has方法的具体用法?C# ContentItem.Has怎么用?C# ContentItem.Has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orchard.ContentManagement.ContentItem
的用法示例。
在下文中一共展示了ContentItem.Has方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AreEqual
private static bool AreEqual(ContentItem item1, ContentItem item2, XElement item1Export, XElement item2Export)
{
//todo: this is a little too generous
if (!item1.SharesIdentifierWith(item2))
return false;
if (item1.Has<TitlePart>() && item2.Has<TitlePart>())
{
if (!item1.As<TitlePart>().Title.Equals(item2.As<TitlePart>().Title, StringComparison.CurrentCulture))
{
return false;
}
}
if (item1.Has<BodyPart>() && item2.Has<BodyPart>())
{
var text1 = item1.As<BodyPart>().Text;
var text2 = item2.As<BodyPart>().Text;
if (text1 == null || text2 == null)
return false;
if (!item1.As<BodyPart>().Text.Equals(item2.As<BodyPart>().Text, StringComparison.CurrentCulture))
{
return false;
}
}
// compare xml elements
return Differences(item1Export, item2Export) == 0;
}
示例2: SharesIdentifierWith
public static bool SharesIdentifierWith(this ContentItem item1, ContentItem item2)
{
if (item1.Has<IdentityPart>() && item2.Has<IdentityPart>())
{
return item1.As<IdentityPart>().Identifier.Equals(item2.As<IdentityPart>().Identifier,
StringComparison.InvariantCultureIgnoreCase);
}
return false;
}
示例3: GetContentItemNode
private TreeNode GetContentItemNode(ContentItem item) {
return new TreeNode {
Title = _contentManager.GetItemMetadata(item).DisplayText,
Type = "content-item-" + item.Id,
Id = item.Id.ToString(CultureInfo.InvariantCulture),
Url = _url.ItemEditUrl(item),
IsLeaf = !item.Has<ContainerPart>()
};
}
示例4: GetUniqueIdentifier
private static string GetUniqueIdentifier(ContentItem item)
{
string slug = null;
if (item.Has<AutoroutePart>())
{
var route = item.Get<AutoroutePart>();
slug = route.Path;
}
return string.Format("{0} {1}", item.Id, slug);
}
示例5: GetUniqueIdentifier
public string GetUniqueIdentifier(ContentItem item)
{
string slug = null;
if (item.Has<RoutePart>())
{
var route = item.Get<RoutePart>();
slug = route.Slug;
}
return string.Format("{0} {1}", item.Id, slug);
}
示例6: IsValid
private bool IsValid(int itemId, out ContentItem item, out ActionResult invalidResult)
{
if (_orchardServices.WorkContext.CurrentUser == null || !_orchardServices.Authorizer.Authorize(Permissions.WatchItems))
{
invalidResult = new HttpUnauthorizedResult();
item = null;
return false;
}
item = _orchardServices.ContentManager.Get(itemId);
if (item == null)
{
invalidResult = HttpNotFound();
return false;
}
if (!_orchardServices.Authorizer.Authorize(Orchard.Core.Contents.Permissions.ViewContent))
{
invalidResult = new HttpUnauthorizedResult();
return false;
}
if (!item.Has<WatchablePart>())
{
invalidResult = HttpNotFound();
return false;
}
invalidResult = null;
return true;
}
示例7: TestShape
public void TestShape(dynamic Display, TextWriter Output, HtmlHelper Html, ContentItem item) {
if (item.Has<IdentityPart>()) {
Output.Write("testshape: " + item.As<IdentityPart>().Identifier);
}
}