标签:
// 取得选中权限集合
string[] arrAuthorityId = this.hidAuthorityIds.Value.TrimEnd(‘,‘).Split(‘,‘);
BLBQ_Authority authority = new BLBQ_Authority();
// 遍历权限集合
foreach (var authorityId in arrAuthorityId)
{
// 通过反射获取对应属性
PropertyInfo pi = authority.GetType().GetProperty(authorityId);
// 属性存在且可写
if (null != pi && pi.CanWrite)
{
// 权限设置为1
pi.SetValue(authority, "1", null);
}
else
{
throw new Exception();
}
}
标签:
原文地址:http://www.cnblogs.com/yuangel/p/4793601.html