本文整理汇总了C#中System.Security.Permissions.FileIOPermission.Union方法的典型用法代码示例。如果您正苦于以下问题:C# FileIOPermission.Union方法的具体用法?C# FileIOPermission.Union怎么用?C# FileIOPermission.Union使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Permissions.FileIOPermission
的用法示例。
在下文中一共展示了FileIOPermission.Union方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Union_Bug79118
public void Union_Bug79118 ()
{
string[] f1 = unix ? new string[] { "/tmp/one", "/tmp/two" } : new string[] { "c:\\temp\\one", "c:\\temp\\two" };
string[] f2 = unix ? new string[] { "/tmp/two" } : new string[] { "c:\\temp\\two" };
p = new FileIOPermission (FileIOPermissionAccess.Read, f1);
p2 = new FileIOPermission (FileIOPermissionAccess.Read, f2);
FileIOPermission union = (FileIOPermission) p.Union (p2);
string[] paths = union.GetPathList(FileIOPermissionAccess.Read);
Assert.AreEqual (2, paths.Length, "Length");
Assert.AreEqual (f1[0], paths[0], "0");
Assert.AreEqual (f1[1], paths[1], "1");
}
示例2: Partial
private void Partial (string msg, string[] path1, string[] path2, int expected)
{
p = new FileIOPermission (FileIOPermissionAccess.Read, path1);
p2 = new FileIOPermission (FileIOPermissionAccess.Read, path2);
FileIOPermission union = (FileIOPermission) p.Union (p2);
string[] paths = union.GetPathList(FileIOPermissionAccess.Read);
Assert.AreEqual (expected, paths.Length, msg + ".Length");
Assert.AreEqual (path1[0], paths[0], msg + "[0]");
if (expected > 1)
Assert.AreEqual (path2[0], paths[1], msg + "[1]");
}
示例3: Union
public void Union ()
{
unrestricted = new FileIOPermission(PermissionState.Unrestricted);
p = new FileIOPermission(FileIOPermissionAccess.Read, pathArrayGood);
FileIOPermission union = (FileIOPermission)unrestricted.Union(p);
pathsInPermission = union.GetPathList(FileIOPermissionAccess.Read);
Assert.IsTrue(union.IsUnrestricted(), "Should get an unrestricted permission");
Assert.IsTrue(pathsInPermission == null, "Path list should be empty");
union = (FileIOPermission)p.Union(unrestricted);
pathsInPermission = union.GetPathList(FileIOPermissionAccess.Read);
Assert.IsTrue(union.IsUnrestricted(), "Should get an unrestricted permission");
Assert.IsTrue(pathsInPermission == null, "Path list should be empty");
p2 = new FileIOPermission(FileIOPermissionAccess.Append, pathArrayGood2);
union = (FileIOPermission)p.Union(p2);
pathsInPermission = union.GetPathList(FileIOPermissionAccess.Read);
Assert.IsTrue(pathsInPermission.Length == pathArrayGood.Length, "Path list should have 2 for Read");
pathsInPermission = union.GetPathList(FileIOPermissionAccess.Append);
Assert.IsTrue(pathsInPermission.Length == pathArrayGood2.Length, "Path list should have 3 for Append");
union = (FileIOPermission)p2.Union(p);
pathsInPermission = union.GetPathList(FileIOPermissionAccess.Read);
Assert.IsTrue(pathsInPermission.Length == pathArrayGood.Length, "Path list should have 2 for Read");
pathsInPermission = union.GetPathList(FileIOPermissionAccess.Append);
Assert.IsTrue(pathsInPermission.Length == pathArrayGood2.Length, "Path list should have 3 for Append");
}