本文整理汇总了C#中System.Security.NamedPermissionSet.Demand方法的典型用法代码示例。如果您正苦于以下问题:C# NamedPermissionSet.Demand方法的具体用法?C# NamedPermissionSet.Demand怎么用?C# NamedPermissionSet.Demand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.NamedPermissionSet
的用法示例。
在下文中一共展示了NamedPermissionSet.Demand方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Work
// S1006/ImperativeSecurity
public static void Work()
{
NamedPermissionSet permissions = new NamedPermissionSet("Custom");
permissions.Demand();
SecureClass.RevertDocument();
}
示例2: Access
public static void Access()
{
// This security check fails if the caller
// does not have full trust.
NamedPermissionSet pset= new NamedPermissionSet("FullTrust");
// This try-catch block shows the caller's permissions.
// Correct code would either not catch the exception,
// or would rethrow it.
try
{
pset.Demand();
}
catch (SecurityException e)
{
Console.WriteLine("Demand for full trust:{0}", e.Message);
}
// Call the type that requires full trust.
// Violates rule AptcaMethodsShouldOnlyCallAptcaMethods.
ClassRequiringFullTrust.DoWork();
}
开发者ID:terryjintry,项目名称:OLSource1,代码行数:21,代码来源:ca2116--aptca-methods-should-only-call-aptca-methods_2.cs