/// <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);
}