/// <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 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)
        {
            FileIOPermission fileIOPermission = FileIOPermission.Cast(other);

            if (fileIOPermission == null)
            {
                return(this.Copy());
            }
            if (this.IsUnrestricted() || fileIOPermission.IsUnrestricted())
            {
                return(new FileIOPermission(PermissionState.Unrestricted));
            }
            if (this.IsEmpty() && fileIOPermission.IsEmpty())
            {
                return(null);
            }
            FileIOPermission fileIOPermission2 = (FileIOPermission)this.Copy();

            fileIOPermission2.AllFiles      |= fileIOPermission.AllFiles;
            fileIOPermission2.AllLocalFiles |= fileIOPermission.AllLocalFiles;
            string[] array = fileIOPermission.GetPathList(FileIOPermissionAccess.Read);
            if (array != null)
            {
                FileIOPermission.UnionKeys(fileIOPermission2.readList, array);
            }
            array = fileIOPermission.GetPathList(FileIOPermissionAccess.Write);
            if (array != null)
            {
                FileIOPermission.UnionKeys(fileIOPermission2.writeList, array);
            }
            array = fileIOPermission.GetPathList(FileIOPermissionAccess.Append);
            if (array != null)
            {
                FileIOPermission.UnionKeys(fileIOPermission2.appendList, array);
            }
            array = fileIOPermission.GetPathList(FileIOPermissionAccess.PathDiscovery);
            if (array != null)
            {
                FileIOPermission.UnionKeys(fileIOPermission2.pathList, array);
            }
            return(fileIOPermission2);
        }