您的位置:首页 > 其它

权限

2015-10-14 14:38 169 查看
#region 权限

        #region 获取权限集合 [1:(1,2,3)|1:(1,2,3)  ]

        /// <summary>

        /// 获取权限集合 [1:(1,2,3)|1:(1,2,3)  ]

        /// </summary>

        /// <param name="str">权限字符串</param>

        /// <returns>返回结果的数据集</returns>

        public static List<RoleKeyValue> GetRole(string str)

        {

            List<RoleKeyValue> result = new List<RoleKeyValue>();

            RoleKeyValue model = null;

            if (!string.IsNullOrEmpty(str))

            {

                string[] s = str.Split('|');

                if (s != null)

                {

                    string[] s1 = null;

                    s = s.Take(s.Length - 1).ToArray();

                    for (int i = 0; i < s.Length; i++)

                    {

                        s1 = s[i].Split(':');

                        model = new RoleKeyValue()

                        {

                            key = s1[0],

                            value = s1[1]

                        };

                        result.Add(model);

                    }

                }

            }

            return result;

        } 

        #endregion

        public class RoleKeyValue 

        {

            public string key { get; set; }

            public string value { get; set; }

        }

        #endregion
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  .net