/// <summary>创建一个权限,该权限是当前权限与指定权限的并集。</summary>
/// <returns>一个新权限,它表示当前权限与指定权限的并集。</returns>
/// <param name="other">将与当前权限合并的权限。它必须与当前权限属于同一类型。</param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="other" /> 参数不是 null,而且与当前权限不是同一类型。</exception>
public override IPermission Union(IPermission other)
{
if (other == null)
{
return(this.Copy());
}
FileIOPermission fileIoPermission = other as FileIOPermission;
if (fileIoPermission == null)
{
throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", (object)this.GetType().FullName));
}
if (this.IsUnrestricted() || fileIoPermission.IsUnrestricted())
{
return((IPermission) new FileIOPermission(PermissionState.Unrestricted));
}
FileIOAccess fileIoAccess1 = this.m_read == null ? fileIoPermission.m_read : this.m_read.Union(fileIoPermission.m_read);
FileIOAccess fileIoAccess2 = this.m_write == null ? fileIoPermission.m_write : this.m_write.Union(fileIoPermission.m_write);
FileIOAccess fileIoAccess3 = this.m_append == null ? fileIoPermission.m_append : this.m_append.Union(fileIoPermission.m_append);
FileIOAccess fileIoAccess4 = this.m_pathDiscovery == null ? fileIoPermission.m_pathDiscovery : this.m_pathDiscovery.Union(fileIoPermission.m_pathDiscovery);
FileIOAccess fileIoAccess5 = this.m_viewAcl == null ? fileIoPermission.m_viewAcl : this.m_viewAcl.Union(fileIoPermission.m_viewAcl);
FileIOAccess fileIoAccess6 = this.m_changeAcl == null ? fileIoPermission.m_changeAcl : this.m_changeAcl.Union(fileIoPermission.m_changeAcl);
if ((fileIoAccess1 == null || fileIoAccess1.IsEmpty()) && (fileIoAccess2 == null || fileIoAccess2.IsEmpty()) && ((fileIoAccess3 == null || fileIoAccess3.IsEmpty()) && (fileIoAccess4 == null || fileIoAccess4.IsEmpty())) && ((fileIoAccess5 == null || fileIoAccess5.IsEmpty()) && (fileIoAccess6 == null || fileIoAccess6.IsEmpty())))
{
return((IPermission)null);
}
return((IPermission) new FileIOPermission(PermissionState.None)
{
m_unrestricted = false, m_read = fileIoAccess1, m_write = fileIoAccess2, m_append = fileIoAccess3, m_pathDiscovery = fileIoAccess4, m_viewAcl = fileIoAccess5, m_changeAcl = fileIoAccess6
});
}