c# - 主要权限(属性)如何工作?

标签 c# .net security attributes

我正在构建一个自定义声明性安全属性,类似于PrincipalPermissionAttribute。对 .net Framework 中的属性体系结构进行一些研究后,只有在调用 Type.GetCustomAttributes 时才会实例化属性。 See Here, And Here

那么,如果方法属性从未实例化过,PrincipalPermissionAttribute 如何能够在运行时断言安全操作呢?我找不到任何有关PrincipalPermissionAttribute实际如何工作的文档。谢谢。

最佳答案

CLR 实际上会查找并触发继承自 System.Security.Permissions.CodeAccessSecurityAttribute 的属性实例的运行时执行。 。如果您想构建一个声明性安全属性而不诉诸 AOP 扩展,您几乎必须从此类继承。

关于c# - 主要权限(属性)如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16921326/

相关文章:

c# - 如何在 C# 9 中复制/克隆记录?

PHP、Linux、 Apache : naming file based on user input

c# - 什么是 C# 静态字段命名约定?

c# - 如何在 WPF 中保存应用程序主题名称

.net - "referenced assembly"如何验证 "caller assembly"的签名/真实性?

node.js - JSON Web token - 有效负载中的密码?

c# - 在使用 Powershell Api 时,有什么方法可以在 C# 中将 PSObject 转换为字符串

c# - 无法添加或更新 Azure AD 应用程序

c# - 以任何形式(Json、xml 等)序列化 Dictionary<String、Dictionary<String、String>>

c# - Windows 窗体,启用禁用控件取决于