/// <summary>
        /// Establishes the composite menu hierarchy which is present on all pages.
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // Build the composite menu tree
                // This tree implements the Composite Design Pattern.
                var root = new MenuCompositeItem("root", null);
                var home = new MenuCompositeItem("home", UrlMaker.ToDefault());
                var shop = new MenuCompositeItem("shopping", UrlMaker.ToShopping());
                var prod = new MenuCompositeItem("products", UrlMaker.ToProducts());
                var srch = new MenuCompositeItem("search", UrlMaker.ToSearch());
                var cart = new MenuCompositeItem("cart", UrlMaker.ToCart());
                var admn = new MenuCompositeItem("administration", UrlMaker.ToAdmin());
                var cust = new MenuCompositeItem("customers", UrlMaker.ToCustomers());
                var ordr = new MenuCompositeItem("orders", UrlMaker.ToOrders());

                MenuCompositeItem auth;
                if (Request.IsAuthenticated)
                {
                    auth = new MenuCompositeItem("logout", UrlMaker.ToLogout());
                }
                else
                {
                    auth = new MenuCompositeItem("login", UrlMaker.ToLogin());
                }

                shop.Children.Add(prod);
                shop.Children.Add(srch);
                shop.Children.Add(cart);
                admn.Children.Add(cust);
                admn.Children.Add(ordr);
                root.Children.Add(home);
                root.Children.Add(shop);
                root.Children.Add(admn);
                root.Children.Add(auth);


                TheMenuComposite.MenuItems = root;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Establishes the composite menu hierarchy which is present on all pages.
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // Build the composite menu tree
                // This tree implements the Composite Design Pattern.
                MenuCompositeItem root = new MenuCompositeItem("root", null);
                MenuCompositeItem home = new MenuCompositeItem("home", ResolveUrl("~/Default.aspx"));
                MenuCompositeItem shop = new MenuCompositeItem("shopping", ResolveUrl("~/WebShop/Shopping.aspx"));
                MenuCompositeItem prod = new MenuCompositeItem("products", ResolveUrl("~/WebShop/Products.aspx"));
                MenuCompositeItem srch = new MenuCompositeItem("search", ResolveUrl("~/WebShop/Search.aspx"));
                MenuCompositeItem cart = new MenuCompositeItem("cart", ResolveUrl("~/WebShop/Cart.aspx"));
                MenuCompositeItem admn = new MenuCompositeItem("administration", ResolveUrl("~/WebAdmin/Admin.aspx"));
                MenuCompositeItem cust = new MenuCompositeItem("customers", ResolveUrl("~/WebAdmin/Customers.aspx"));
                MenuCompositeItem ordr = new MenuCompositeItem("orders", ResolveUrl("~/WebAdmin/Orders.aspx"));

                MenuCompositeItem auth;
                if (Request.IsAuthenticated)
                {
                    auth = new MenuCompositeItem("logout", ResolveUrl("~/Logout.aspx"));
                }
                else
                {
                    auth = new MenuCompositeItem("login", ResolveUrl("~/Login.aspx"));
                }

                shop.Children.Add(prod);
                shop.Children.Add(srch);
                shop.Children.Add(cart);
                admn.Children.Add(cust);
                admn.Children.Add(ordr);
                root.Children.Add(home);
                root.Children.Add(shop);
                root.Children.Add(admn);
                root.Children.Add(auth);

                TheMenuComposite.MenuItems = root;
            }
        }