Skip to content

Instantly share code, notes, and snippets.

@toburger
Forked from moaschterle/gist:5204993
Last active December 15, 2015 04:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toburger/5204998 to your computer and use it in GitHub Desktop.
Save toburger/5204998 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Intranet
{
public static class MenuExtensions
{
public static IMenu NextSibling(this IMenu menu)
{
if (menu.Parent == null)
throw new InvalidOperationException("I'm the root menu node, I have no parents!");
return (from n in menu.Parent.Nodes
where n.Order >= menu.Order
orderby n.Order
select n).FirstOrDefault();
}
public static IMenu NextParent(this IMenu menu)
{
return menu.Parent.NextSibling();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment