public ViewBaseModel(BaseController controller) { if (controller == null) { throw new ArgumentNullException("controller"); } this._isLogin = controller.IsLogin; this._isVirtualAccount = controller.IsVirtualAccount; this._loginUserInfo = string.Format(SiteCommonResource.TextFormatUserInfo, controller.LoginUserName, controller.LoginAccount); HttpContext context = HttpContext.Current; SiteMenuModel menuRoot = CacheManager.GetSiteMenus(context); this._rootMenus = menuRoot.SubMenus; string relativePath = string.Format("~/{0}/{1}", controller.ValueProvider.GetValue("controller").RawValue, controller.ValueProvider.GetValue("action").RawValue); SiteMenuModel siteMenuCurrentNode = SiteMenuModel.GetSiteMenuCurrentNode(relativePath); if (siteMenuCurrentNode != null) { this._currentRootMenu = siteMenuCurrentNode; while (this._currentRootMenu.ParentMenu != null && this._currentRootMenu.ParentMenu != menuRoot) { this._currentRootMenu = this._currentRootMenu.ParentMenu; } } this._breadCrumbCurrentNode = SiteMenuModel.GetBreadCrumbCurrentNode(relativePath); if (this._breadCrumbCurrentNode != null) { this._breadCrumb = new List<SiteMenuModel>(); SiteMenuModel parentNode = this._breadCrumbCurrentNode.ParentMenu; while (parentNode != null) { this._breadCrumb.Insert(0, parentNode); parentNode = parentNode.ParentMenu; } } }
private void UpdateActionDictionary(SiteMenuModel menu, Dictionary<string, SiteMenuModel> dictionary) { if (menu == null) { return; } if (menu.IsAction && !string.IsNullOrWhiteSpace(menu.Url) && !dictionary.ContainsKey(menu.Url)) { dictionary.Add(menu.Url, menu); } if (menu.SubMenus != null) { foreach (SiteMenuModel subMenu in menu.SubMenus) { UpdateActionDictionary(subMenu, dictionary); subMenu.ParentMenu = menu; } } }
public bool ContainSiteMenuCurrentNode(SiteMenuModel rootMenu) { return this._currentRootMenu != null && this._currentRootMenu == rootMenu; }