示例#1
0
文件: Utility.cs 项目: mokth/merpV3
        public static AccessRights GetAccessRightsByString(string rights)
        {
            AccessRights right = new AccessRights();
            Type         rtype = right.GetType();

            AccessRightField rightdesc = new AccessRightField();
            Type             ftype     = rightdesc.GetType();

            string[] keys = rights.Split(new char[] { ',' });
            foreach (string key in keys)
            {
                FieldInfo finfo = ftype.GetField(key);
                if (finfo != null)
                {
                    string       fname = finfo.GetValue(rightdesc).ToString();
                    PropertyInfo pinfo = rtype.GetProperty(fname);
                    if (pinfo != null)
                    {
                        pinfo.SetValue(right, true);
                    }
                }
            }

            return(right);
        }
示例#2
0
文件: Utility.cs 项目: mokth/merpV3
        public static AccessRights GetAccessRightsByString(string rights)
        {
            AccessRights right = new AccessRights();
            Type rtype = right.GetType();

            AccessRightField rightdesc = new AccessRightField();
            Type ftype = rightdesc.GetType();
            string[] keys = rights.Split(new char[] { ',' });
            foreach (string key in keys)
            {
                FieldInfo finfo = ftype.GetField(key);
                if (finfo != null)
                {
                    string fname=  finfo.GetValue(rightdesc).ToString();
                    PropertyInfo pinfo = rtype.GetProperty(fname);
                    if (pinfo != null)
                    {
                        pinfo.SetValue(right, true);
                    }
                }
            }

            return right;
        }