【发布时间】:2020-01-11 08:32:14
【问题描述】:
我的项目中有一些类,一些属性是Browsable(false),所以用户看不到它们:
public class OrderEntity{
public int Id { get; set;}
[Browsable(false)]
public int ProductId { get; set;}
....
}
我想,如果最终用户是管理员,他可以看到ProductId,但其他用户看不到。
所以我需要这样的东西:
public class OrderEntity{
public int Id { get; set;}
[CustomizedBrowsable(false)]
public int ProductId { get; set;}
....
}
public class CustomizedBrowsable: Attribute
{
if(AppContext.UserCode == "Admin") // The current user code saved in a static variable AppContext.UserCode.
//do somethings
else
//do somethings else
}
【问题讨论】:
标签: c# winforms attributes browsable