本文整理汇总了C#中System.Item.Url方法的典型用法代码示例。如果您正苦于以下问题:C# Item.Url方法的具体用法?C# Item.Url怎么用?C# Item.Url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Item
的用法示例。
在下文中一共展示了Item.Url方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateNavigationItem
private NavigationItem CreateNavigationItem(Item item, int level, int maxLevel = -1)
{
return new NavigationItem
{
Item = item,
Url = (item.IsDerived(Templates.Link.ID) ? item.LinkFieldUrl(Templates.Link.Fields.Link) : item.Url()),
Target = (item.IsDerived(Templates.Link.ID) ? item.LinkFieldTarget(Templates.Link.Fields.Link) : ""),
IsActive = this.IsItemActive(item),
Children = this.GetChildNavigationItems(item, level + 1, maxLevel)
};
}
示例2: GetPageLinkOrDefault
public virtual string GetPageLinkOrDefault(Item contextItem, ID field, Item defaultItem)
{
Assert.ArgumentNotNull(defaultItem, nameof(defaultItem));
try
{
return this.GetPageLink(contextItem, field);
}
catch (Exception ex)
{
Log.Warn(ex.Message, ex, this);
return defaultItem.Url();
}
}
示例3: GetPageLinkOrDefaultShouldReturnDefault
public void GetPageLinkOrDefaultShouldReturnDefault(Item item,ID id, Item defaultItem)
{
var accountSettingsService = Substitute.ForPartsOf<AccountsSettingsService>();
accountSettingsService.When(x => x.GetPageLink(item, id)).DoNotCallBase();
accountSettingsService.GetPageLink(Arg.Any<Item>(), Arg.Any<ID>()).Returns(x => { throw new Exception(); });
var result = accountSettingsService.GetPageLinkOrDefault(item, id, defaultItem);
result.Should().Be(defaultItem.Url());
}
示例4: CreateNavigationItem
private NavigationItem CreateNavigationItem(Item item, int level, int maxLevel = -1)
{
var targetItem = item.IsDerived(Templates.Link.ID) ? item.TargetItem(Templates.Link.Fields.Link) : item;
return new NavigationItem
{
Item = item,
Url = item.IsDerived(Templates.Link.ID) ? item.LinkFieldUrl(Templates.Link.Fields.Link) : item.Url(),
Target = item.IsDerived(Templates.Link.ID) ? item.LinkFieldTarget(Templates.Link.Fields.Link) : "",
IsActive = this.IsItemActive(targetItem ?? item),
Children = this.GetChildNavigationItems(item, level + 1, maxLevel),
ShowChildren = !item.IsDerived(Templates.Navigable.ID) || item.Fields[Templates.Navigable.Fields.ShowChildren].IsChecked()
};
}