本文整理匯總了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()
};
}