对于公共的非密封类:
[System.Security.Permissions.PermissionSetAttribute(System.Security. Permissions.SecurityAction.InheritanceDemand, Name="FullTrust")] [System.Security.Permissions.PermissionSetAttribute (System.Security.Permissions.SecurityAction.LinkDemand, Name="FullTrust")] public class CanDeriveFromMe •对于公共的密封类:
[System.Security.Permissions.PermissionSetAttribute (System.Security.Permissions.SecurityAction.LinkDemand, Name="FullTrust")] public sealed class CannotDeriveFromMe •对于公共的抽象类:
[System.Security.Permissions.PermissionSetAttribute (System.Security.Permissions.SecurityAction.InheritanceDemand, Name="FullTrust")] [System.Security.Permissions.PermissionSetAttribute (System.Security.Permissions.SecurityAction.LinkDemand, Name="FullTrust")] public abstract class CannotCreateInstanceOfMe_CanCastToMe •对于公共的虚拟函数:
class Base { [System.Security.Permissions.PermissionSetAttribute (System.Security.Permissions.SecurityAction.InheritanceDemand, Name="FullTrust")] [System.Security.Permissions.PermissionSetAttribute( System.Security.Permissions.SecurityAction.LinkDemand, Name="FullTrust")] public override void CanOverrideOrCallMe() { ... } •对于公共的抽象函数:
class Base { [System.Security.Permissions.PermissionSetAttribute (System.Security.Permissions.SecurityAction.InheritanceDemand, Name="FullTrust")] [System.Security.Permissions.PermissionSetAttribute (System.Security.Permissions.SecurityAction.LinkDemand, Name="FullTrust")] public override void CanOverrideMe() { ... } •对于基函数不需要完全信任的公共重写函数:
class Derived { [System.Security.Permissions.PermissionSetAttribute (System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")] public override void CanOverrideOrCallMe() { ... } •对于基函数需要完全信任的公共重写函数:
class Derived { [System.Security.Permissions.PermissionSetAttribute (System.Security.Permissions.SecurityAction.LinkDemand, Name="FullTrust")] public override void CanOverrideOrCallMe() { ... } •对于公共接口:
[System.Security.Permissions.PermissionSetAttribute (System.Security.Permissions.SecurityAction.InheritanceDemand, Name="FullTrust")] [System.Security.Permissions.PermissionSetAttribute (System.Security.Permissions.SecurityAction.LinkDemand, Name="FullTrust")] public interface CanCastToMe Demand 与 LinkDemand声明性安全提供了两种类似的、但检查方式大不相同的安全检查。花些时间了解这两种形式是值得的,因为错误的选择会导致脆弱的安全性或性能损失。本部分并不打算完整地说明这些功能;有关完整的详细信息,请参阅产品文档。
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/