public override IPermission Union(IPermission other) { EnvironmentPermission ep = Cast(other); if (ep == null) { return(Copy()); } if (IsUnrestricted() || ep.IsUnrestricted()) { return(new EnvironmentPermission(PermissionState.Unrestricted)); } if (IsEmpty() && ep.IsEmpty()) { return(null); } EnvironmentPermission result = (EnvironmentPermission)Copy(); string path = ep.GetPathList(EnvironmentPermissionAccess.Read); if (path != null) { result.AddPathList(EnvironmentPermissionAccess.Read, path); } path = ep.GetPathList(EnvironmentPermissionAccess.Write); if (path != null) { result.AddPathList(EnvironmentPermissionAccess.Write, path); } return(result); }
/// <summary>Creates a permission that is the union of the current permission and the specified permission.</summary> /// <returns>A new permission that represents the union of the current permission and the specified permission.</returns> /// <param name="other">A permission to combine with the current permission. It must be of the same type as the current permission. </param> /// <exception cref="T:System.ArgumentException">The <paramref name="other" /> parameter is not null and is not of the same type as the current permission. </exception> public override IPermission Union(IPermission other) { EnvironmentPermission environmentPermission = this.Cast(other); if (environmentPermission == null) { return(this.Copy()); } if (this.IsUnrestricted() || environmentPermission.IsUnrestricted()) { return(new EnvironmentPermission(PermissionState.Unrestricted)); } if (this.IsEmpty() && environmentPermission.IsEmpty()) { return(null); } EnvironmentPermission environmentPermission2 = (EnvironmentPermission)this.Copy(); string pathList = environmentPermission.GetPathList(EnvironmentPermissionAccess.Read); if (pathList != null) { environmentPermission2.AddPathList(EnvironmentPermissionAccess.Read, pathList); } pathList = environmentPermission.GetPathList(EnvironmentPermissionAccess.Write); if (pathList != null) { environmentPermission2.AddPathList(EnvironmentPermissionAccess.Write, pathList); } return(environmentPermission2); }