本文整理汇总了C#中System.Security.Permissions.EnvironmentPermission.AddPathList方法的典型用法代码示例。如果您正苦于以下问题:C# EnvironmentPermission.AddPathList方法的具体用法?C# EnvironmentPermission.AddPathList怎么用?C# EnvironmentPermission.AddPathList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Permissions.EnvironmentPermission
的用法示例。
在下文中一共展示了EnvironmentPermission.AddPathList方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreatePermission
// Methods
public override IPermission CreatePermission ()
{
#if NET_2_1
return null;
#else
EnvironmentPermission perm = null;
if (this.Unrestricted)
perm = new EnvironmentPermission (PermissionState.Unrestricted);
else {
perm = new EnvironmentPermission (PermissionState.None);
if (read != null)
perm.AddPathList (EnvironmentPermissionAccess.Read, read);
if (write != null)
perm.AddPathList (EnvironmentPermissionAccess.Write, write);
}
return perm;
#endif
}
示例2: Intersect
public override IPermission Intersect (IPermission target)
{
EnvironmentPermission ep = Cast (target);
if (ep == null)
return null;
if (IsUnrestricted ())
return ep.Copy ();
if (ep.IsUnrestricted ())
return Copy ();
int n = 0;
EnvironmentPermission result = new EnvironmentPermission (PermissionState.None);
string readTarget = ep.GetPathList (EnvironmentPermissionAccess.Read);
if (readTarget != null) {
string[] targets = readTarget.Split (';');
foreach (string t in targets) {
if (readList.Contains (t)) {
result.AddPathList (EnvironmentPermissionAccess.Read, t);
n++;
}
}
}
string writeTarget = ep.GetPathList (EnvironmentPermissionAccess.Write);
if (writeTarget != null) {
string[] targets = writeTarget.Split (';');
foreach (string t in targets) {
if (writeList.Contains (t)) {
result.AddPathList (EnvironmentPermissionAccess.Write, t);
n++;
}
}
}
return ((n > 0) ? result : null);
}
示例3: GetPathList
public void GetPathList ()
{
EnvironmentPermission ep = new EnvironmentPermission (PermissionState.None);
#if NET_2_0
AssertEquals ("GetPathList-Read-Empty", String.Empty, ep.GetPathList (EnvironmentPermissionAccess.Read));
AssertEquals ("GetPathList-Write-Empty", String.Empty, ep.GetPathList (EnvironmentPermissionAccess.Write));
#else
AssertNull ("GetPathList-Read-Empty", ep.GetPathList (EnvironmentPermissionAccess.Read));
AssertNull ("GetPathList-Write-Empty", ep.GetPathList (EnvironmentPermissionAccess.Write));
#endif
ep.AddPathList (EnvironmentPermissionAccess.Read, "UID");
ep.AddPathList (EnvironmentPermissionAccess.Write, "PROMPT");
AssertEquals ("GetPathList-Read", "UID", ep.GetPathList (EnvironmentPermissionAccess.Read));
AssertEquals ("GetPathList-Write", "PROMPT", ep.GetPathList (EnvironmentPermissionAccess.Write));
}
示例4: GetPathListNoAccess
public void GetPathListNoAccess ()
{
EnvironmentPermission ep = new EnvironmentPermission (PermissionState.None);
ep.AddPathList (EnvironmentPermissionAccess.Read, "UID");
ep.AddPathList (EnvironmentPermissionAccess.Write, "PROMPT");
AssertEquals ("GetPathList-NoAccess", "", ep.GetPathList (EnvironmentPermissionAccess.NoAccess));
}
示例5: AddPathList
public void AddPathList ()
{
EnvironmentPermission ep = new EnvironmentPermission (PermissionState.None);
ep.AddPathList (EnvironmentPermissionAccess.AllAccess, envVariables);
// LAMESPEC NoAccess do not remove the TMP from AllAccess
ep.AddPathList (EnvironmentPermissionAccess.NoAccess, "TMP");
ep.AddPathList (EnvironmentPermissionAccess.Read, "UID");
ep.AddPathList (EnvironmentPermissionAccess.Write, "PROMPT");
SecurityElement se = ep.ToXml ();
// Note: Debugger can mess results (try to run without stepping)
AssertEquals ("AddPathList-ToXml-Read", "TMP;TEMP;UID", (se.Attributes ["Read"] as string));
AssertEquals ("AddPathList-ToXml-Write", "TMP;TEMP;PROMPT", (se.Attributes ["Write"] as string));
}
示例6: GetPathListAllAccess
public void GetPathListAllAccess ()
{
EnvironmentPermission ep = new EnvironmentPermission (PermissionState.None);
ep.AddPathList (EnvironmentPermissionAccess.Read, "UID");
ep.AddPathList (EnvironmentPermissionAccess.Write, "PROMPT");
Assert.AreEqual ("", ep.GetPathList (EnvironmentPermissionAccess.AllAccess), "GetPathList-AllAccess");
}
示例7: CreateStackWalk
protected override IStackWalk CreateStackWalk()
{
EnvironmentPermission permission = new EnvironmentPermission(PermissionState.Unrestricted);
permission.AddPathList(attribute.Flag, attribute.PathList);
return permission;
}
示例8: GetPathList
public void GetPathList ()
{
EnvironmentPermission ep = new EnvironmentPermission (PermissionState.None);
Assert.AreEqual (String.Empty, ep.GetPathList (EnvironmentPermissionAccess.Read), "GetPathList-Read-Empty");
Assert.AreEqual (String.Empty, ep.GetPathList (EnvironmentPermissionAccess.Write), "GetPathList-Write-Empty");
ep.AddPathList (EnvironmentPermissionAccess.Read, "UID");
ep.AddPathList (EnvironmentPermissionAccess.Write, "PROMPT");
Assert.AreEqual ("UID", ep.GetPathList (EnvironmentPermissionAccess.Read), "GetPathList-Read");
Assert.AreEqual ("PROMPT", ep.GetPathList (EnvironmentPermissionAccess.Write), "GetPathList-Write");
}