本文整理汇总了C#中ContentItem.GetParent方法的典型用法代码示例。如果您正苦于以下问题:C# ContentItem.GetParent方法的具体用法?C# ContentItem.GetParent怎么用?C# ContentItem.GetParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContentItem
的用法示例。
在下文中一共展示了ContentItem.GetParent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsLocallyUnique
/// <summary>Find out if an item name is occupied.</summary>
/// <param name="name">The name to check.</param>
/// <param name="item">The item whose siblings (other items with the same parent) might be have a clashing name.</param>
/// <returns>True if the name is unique.</returns>
public bool IsLocallyUnique(string name, ContentItem item)
{
//this causes an error if in install mode due to the root node not being installed yet so can't add Language Container which is needed to check if root node is unique!
//so check mode - if in install it's safe to assume this code isn't needed
if (_adminConfig.Installer.Mode != InstallationMode.Install)
{
ContentItem parentItem = item.GetParent();
if (parentItem != null)
foreach (ContentItem potentiallyClashingItem in parentItem.Children)
if (!potentiallyClashingItem.Equals(item) && potentiallyClashingItem != item.TranslationOf)
foreach (ContentItem translation in _languageManager.GetTranslationsOf(potentiallyClashingItem, true))
if (!translation.Equals(item) && translation.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase))
return false;
}
return true;
}
示例2: GetSaveException
/// <summary>Check if an item can be saved.</summary>
/// <exception cref="NameOccupiedException"></exception>
/// <exception cref="ZeusException"></exception>
public virtual ZeusException GetSaveException(ContentItem item)
{
if (!IsLocallyUnique(item.Name, item))
return new NameOccupiedException(item, item.GetParent());
if (!IsTypeAllowedBelowDestination(item, item.Parent))
return new NotAllowedParentException(_contentTypeManager.GetContentType(item.GetType()), item.GetParent().GetType());
return null;
}