예제 #1
0
        private void SetMenuDetail(Type t)
        {
            MenuDetailAttribute menuattr = t?.GetCustomAttribute <MenuDetailAttribute>();
            MenuDetailModel     menu     = menuattr?.GetModel();

            if (menu == null)
            {
                return;
            }
            menu.Namespace = t.Namespace;
            if (m_menu.ContainsKey(menu.Id))
            {
                if (m_menu[menu.Id] == menu)
                {
                    return;
                }
                throw new Exception($"{menu.Name}的Id值与{m_menu[menu.Id].Name}中的Id值重复");
            }
            m_controller.Add(t.FullName, menu);
            m_menu.Add(menu.Id, menu);
            if (!m_menupid.TryGetValue(menu.Pid, out HashSet <int> pids))
            {
                pids = new HashSet <Int32>();
                m_menupid.Add(menu.Pid, pids);
            }
            pids.Add(menu.Id);
            SetActionDetail(t, menu.Id);
        }
예제 #2
0
 public static Boolean EqualWith(this MenuDetailModel detail, ActionDetailModel other)
 {
     if (other == null)
     {
         return(false);
     }
     return(detail.Id == other.Id);
 }
예제 #3
0
        public Tuple <MenuDetailModel, ActionDetailModel> IdToMenu(String id)
        {
            String[]          arr    = id.Split(new String[] { "!&" }, StringSplitOptions.RemoveEmptyEntries);
            MenuDetailModel   menu   = m_menu[Convert.ToInt32(arr[0])];
            ActionDetailModel action = m_menutoaction[Convert.ToInt32(arr[0])].FirstOrDefault(item => item.Id == Convert.ToInt32(arr[1]));

            return(new Tuple <MenuDetailModel, ActionDetailModel>(menu, action));
        }
예제 #4
0
 public MenuDetailAttribute(Int32 id, String name, String classname, Int32 pid, String des, String url)
 {
     m_model             = new MenuDetailModel();
     m_model.Id          = id;
     m_model.Name        = name;
     m_model.Description = des;
     m_model.Url         = url;
     m_model.Classname   = classname;
     m_model.Pid         = pid;
 }
예제 #5
0
        public String ConvertRouteToId(String space, String controller, String index)
        {
            String fullname = $"{space}.{controller}";;

            if (!controller.EndsWith("Controller"))
            {
                fullname += "Controller";
            }
            MenuDetailModel   menu   = m_controller[fullname];
            ActionDetailModel action = m_menutoaction[Convert.ToInt32(menu.Id)].FirstOrDefault(item => item.Name == index);

            return(ConvertToId(action));
        }
예제 #6
0
 public MenuDetailAttribute(MenuDetailModel model)
 {
     m_model = model;
 }