本文整理匯總了C#中System.Security.PermissionSet.AddPermission方法的典型用法代碼示例。如果您正苦於以下問題:C# PermissionSet.AddPermission方法的具體用法?C# PermissionSet.AddPermission怎麽用?C# PermissionSet.AddPermission使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Security.PermissionSet
的用法示例。
在下文中一共展示了PermissionSet.AddPermission方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: FileDialogPermission
// Add a permission to the permission set.
ps1.AddPermission(
new FileDialogPermission(FileDialogPermissionAccess.Open));
示例2: Main
//引入命名空間
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.IsolatedStorage;
using System.Net;
using System.Net.Sockets;
using System.Reflection;
using System.Security;
using System.Security.AccessControl;
using System.Security.Policy;
using System.Security.Permissions;
using System.Security.Principal;
using System.Text;
public class MainClass
{
public static void Main()
{
AppDomain sandboxAd;
Evidence ev = new Evidence();
ev.AddAssembly(Assembly.GetExecutingAssembly());
PermissionSet permSet = new PermissionSet(PermissionState.None);
permSet.AddPermission(new SecurityPermission(PermissionState.Unrestricted));
permSet.AddPermission(new FileIOPermission(PermissionState.Unrestricted));
sandboxAd = AppDomain.CreateDomain("Sandbox", ev, new AppDomainSetup(), permSet);
sandboxAd.DoCallBack(SecureOperationDeclarative);
}
[FileIOPermission(SecurityAction.Demand, Read=@"C:\")]
private static void SecureOperationDeclarative(){
}
}