我创建了一个自定义属性类,该类将检查系统安全性并在出现安全错误时引发身份验证异常。将具有变量值的自定义属性作为参数传递
public class EntityChecker: System.Attribute
{
public EntityChecker(int entityId)
{
// doing some logic to check if the entityId is allowed to be inserted
}
}
我想用这个自定义属性的声明实体相加功能,我想从功能属性的构造函数传递变量。可以这样做吗?
[EntityChecker(entityId)]
public int AddNewEntity(entityId)
{
// logic of entity addition
}
我在想究竟做同样的事情,以确保我的服务层 –