本文整理汇总了C#中Menu.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# Menu.AddRange方法的具体用法?C# Menu.AddRange怎么用?C# Menu.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Menu
的用法示例。
在下文中一共展示了Menu.AddRange方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitMenu
public void InitMenu()
{
m_Menu = new Menu();
var menuItem1 = new MenuItemWithDelegate("Print Hello", new Action(printHello));
var menuItem2 = new MenuItemWithDelegate("Print Date", new Action(printTheDate));
var menuItem3 = new MenuItemWithDelegate("Print Time", new Action(printTheTime));
m_Menu.AddRange(new MenuItem[] { menuItem1, menuItem2, menuItem3 });
}
示例2: InitializeMainMenu
private static Menu InitializeMainMenu(IEnumerable<Category> categories)
{
var menu = new Menu();
var menuItems = categories.Select(c => new MenuItem
{
ContentId = c.Id,
ContentName = c.Name,
Title = c.Title,
SortOrder = c.SortOrder
});
menu.AddRange(menuItems);
return menu;
}
示例3: SiteModel
public SiteModel(SiteContainer context, string contentName, bool showContentItems = false)
{
Title = "Ольга Шитова";
PageTitle = "Ольга Шитова";
if (contentName == null)
{
Content = context.Content.First(c => c.MainPage);
}
else
{
Content = context.Content.FirstOrDefault(c => c.Name == contentName);
if (Content == null)
{
throw new HttpNotFoundException();
}
}
if (!string.IsNullOrEmpty(Content.Title))
{
if (Content.Title != PageTitle)
PageTitle += " » " + Content.Title;
Title = Content.Title;
}
SeoDescription = Content.SeoDescription;
SeoKeywords = Content.SeoKeywords;
if (Content.MainPage)
{
IsHomePage = true;
}
if (showContentItems)
{
HasContentItems = true;
ContentItems = context.ContentItem.Include("ContentItemImages").OrderBy(ci => ci.SortOrder).ToList();
}
var contents = context.Content.Where(c => !c.MainPage).ToList();
Menu = new Menu();
Menu.AddRange(contents.Select(content => new MenuItem {ContentId = content.Id, ContentName = content.Name, Current = content.Name == contentName, SortOrder = content.SortOrder, Title = content.Title}));
}