/// <summary> /// 通过反射获取当前页面中的权限设置项 /// </summary> /// <returns></returns> private ___ getPageActionListByReflection() { ___ result = null; Type type = this.GetType(); #region 属性 PropertyInfo[] piList = type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); foreach (PropertyInfo pi in piList) { if (pi.PropertyType == typeof(___)) { return((___)pi.GetValue(this, null)); } if (pi.PropertyType.IsSubclassOf(typeof(___))) { return((___)pi.GetValue(this, null)); } } #endregion #region 字段 FieldInfo[] miList = type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); foreach (FieldInfo pi in miList) { if (pi.FieldType == typeof(___)) { return((___)pi.GetValue(this)); } if (pi.FieldType.IsSubclassOf(typeof(___))) { return((___)pi.GetValue(this)); } } #endregion return(result); }
/// <summary> /// 页面权限项初始化 /// </summary> private void PageActionIni() { this.PageDbActionList = dbPage.GetPageActionList(this.PageMenu); this.UserPageDbActionList = dbPage.GetUserPageActionList(this.PageMenu, this.Data.User); ___ action = getPageActionListByReflection(); if (action != null) { action.PageMenu = this.PageMenu; action.User = this.Data.User; action.DbActionList = this.PageDbActionList; action.DbUserActionList = this.UserPageDbActionList; action.IniPageAction(); action.UserBindAction(); } }