public override IPermission Union(IPermission target) { if (target == null) { return(Copy()); } else if (!(target is FileIOPermission)) { throw new ArgumentException(_("Arg_PermissionMismatch")); } else if (IsUnrestricted() || ((FileIOPermission)target).IsUnrestricted()) { return(new FileIOPermission (PermissionState.Unrestricted)); } else { return(new FileIOPermission (PermissionState.None, EnvironmentPermission.Union(readList, ((FileIOPermission)target).readList, false), EnvironmentPermission.Union(writeList, ((FileIOPermission)target).writeList, false), EnvironmentPermission.Union(appendList, ((FileIOPermission)target).appendList, false), EnvironmentPermission.Union(discoveryList, ((FileIOPermission)target).discoveryList, false), allLocalFiles | ((FileIOPermission)target).allLocalFiles, allFiles | ((FileIOPermission)target).allFiles)); } }
// Add to the path list information. public void AddPathList(RegistryPermissionAccess flag, String pathList) { if (pathList == null) { throw new ArgumentNullException("pathList"); } if ((flag & ~(RegistryPermissionAccess.AllAccess)) != 0) { throw new ArgumentException(_("Arg_RegistryAccess")); } if ((flag & RegistryPermissionAccess.Read) != 0) { readList = EnvironmentPermission.Union(readList, EnvironmentPermission.SplitPath (pathList, Path.PathSeparator), false); } if ((flag & RegistryPermissionAccess.Write) != 0) { writeList = EnvironmentPermission.Union(writeList, EnvironmentPermission.SplitPath (pathList, Path.PathSeparator), false); } if ((flag & RegistryPermissionAccess.Create) != 0) { createList = EnvironmentPermission.Union(createList, EnvironmentPermission.SplitPath (pathList, Path.PathSeparator), false); } }
public override IPermission Union(IPermission target) { if (target == null) { return(Copy()); } else if (!(target is RegistryPermission)) { throw new ArgumentException(_("Arg_PermissionMismatch")); } else if (IsUnrestricted() || ((RegistryPermission)target).IsUnrestricted()) { return(new RegistryPermission (PermissionState.Unrestricted)); } else { return(new RegistryPermission (PermissionState.None, EnvironmentPermission.Union(readList, ((RegistryPermission)target).readList, false), EnvironmentPermission.Union(writeList, ((RegistryPermission)target).writeList, false), EnvironmentPermission.Union(createList, ((RegistryPermission)target).createList, false))); } }
public override IPermission Union(IPermission target) { if (target == null) { return(Copy()); } else if (!(target is SiteIdentityPermission)) { throw new ArgumentException(_("Arg_PermissionMismatch")); } else { return(new SiteIdentityPermission (EnvironmentPermission.Union (sites, ((SiteIdentityPermission)target).sites, false))); } }
public void AddPathList(FileIOPermissionAccess access, String[] pathList) { if (pathList == null) { throw new ArgumentNullException("pathList"); } if ((access & ~(FileIOPermissionAccess.AllAccess)) != 0) { throw new ArgumentException(_("Arg_FileIOAccess")); } foreach (String s in pathList) { if (s == null) { throw new ArgumentNullException("pathList element"); } } if ((access & FileIOPermissionAccess.Read) != 0) { readList = EnvironmentPermission.Union (readList, pathList, true); } if ((access & FileIOPermissionAccess.Write) != 0) { writeList = EnvironmentPermission.Union (writeList, pathList, true); } if ((access & FileIOPermissionAccess.Append) != 0) { appendList = EnvironmentPermission.Union (appendList, pathList, true); } if ((access & FileIOPermissionAccess.PathDiscovery) != 0) { discoveryList = EnvironmentPermission.Union (discoveryList, pathList, true); } }
public void UnionWithBadPermission () { EnvironmentPermission ep1 = new EnvironmentPermission (EnvironmentPermissionAccess.Read, envVariables); FileDialogPermission fdp2 = new FileDialogPermission (PermissionState.Unrestricted); EnvironmentPermission ep3 = (EnvironmentPermission) ep1.Union (fdp2); }
public void Union () { EnvironmentPermission ep1 = new EnvironmentPermission (EnvironmentPermissionAccess.Read, envVariables); EnvironmentPermission ep2 = new EnvironmentPermission (EnvironmentPermissionAccess.Write, envVariables); EnvironmentPermission ep3 = (EnvironmentPermission) ep1.Union (ep2); EnvironmentPermission ep4 = new EnvironmentPermission (EnvironmentPermissionAccess.AllAccess, envVariables); AssertEquals ("EP1 U EP2 == EP1+2", ep3.ToXml ().ToString (), ep4.ToXml ().ToString ()); }
public void UnionWithUnrestricted () { EnvironmentPermission ep1 = new EnvironmentPermission (PermissionState.Unrestricted); EnvironmentPermission ep2 = new EnvironmentPermission (EnvironmentPermissionAccess.Read, envVariables); EnvironmentPermission ep3 = (EnvironmentPermission) ep1.Union (ep2); Assert ("Unrestricted U EP2 == Unrestricted", ep3.IsUnrestricted ()); ep3 = (EnvironmentPermission) ep2.Union (ep1); Assert ("EP2 U Unrestricted == Unrestricted", ep3.IsUnrestricted ()); }
public void UnionWithNull () { EnvironmentPermission ep1 = new EnvironmentPermission (EnvironmentPermissionAccess.Read, envVariables); EnvironmentPermission ep2 = null; EnvironmentPermission ep3 = (EnvironmentPermission) ep1.Union (ep2); AssertEquals ("EP1 U null == EP1", ep1.ToXml ().ToString (), ep3.ToXml ().ToString ()); }