我有一个具有静态属性的结构(我不创建该结构的实例,我使用它就像一个类型-commuser.myproperty)。
我写了一个按名称查找属性的方法。我不知道的是,一旦找到那块地产怎么称呼它?比如:
CommUser.item
(项已找到属性)。
public struct CommUser
{
public static string pcUSER_URI_R97
{
get;
set;
}
public static string pcUSER_URI_R98
{
get;
set;
}
}
public bool CheckIfUserHasRights(string[] listUserRights)
{
var listUserProperties = typeof(CommUser).GetProperties(BindingFlags.Static | BindingFlags.Public);
foreach (var item in listUserProperties)
{
foreach (var usrRight in listUserRights)
{
if (item != null && !string.IsNullOrEmpty(item.Name) && !string.IsNullOrEmpty(usrRight))
{
if (item.Name.EndsWith(usrRight))
{
//how to make a call to CommUser.item ?
}
}
}
}
return false;
}