void ReDefineId(JAuthAttribute menu, AppFunction func) { var fOld = mOldList.FirstOrDefault(f => f.IsTheSame(func)); if (fOld != null) { func.Id = fOld.Id; return; } if (menu.Id.IsEmpty()) { return; } var existsFunc = mFuncTrees.FirstOrDefault(f => f.Id == menu.Id); if (existsFunc != null) { throw new ArgumentException( String.Format("不能为功能'{0}'分配Id={1}, 已有相同ID的功能:'{2}'", func.Name, menu.Id, existsFunc.Name)); } func.Id = menu.Id; }
JAuthAttribute GetMenu(Type controllerType, JAuthType defaultAuthType, JLogType defaultLogType) { string controllerName = controllerType.Name.Substring(0, controllerType.Name.Length - 10); var attr = controllerType.GetCustomAttributes(false) .FirstOrDefault(co => co is JAuthAttribute) as JAuthAttribute; if (attr == null) { attr = new JAuthAttribute(defaultAuthType, controllerName); attr.LogType = defaultLogType; } if (attr.Name.IsEmpty()) { attr.Name = controllerName; } if (controllerType.Assembly == this.GetType().Assembly) { attr.AreaName = "/AppCenter"; } return(attr); }