/// <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)
{
RegistryPermission registryPermission = this.Cast(other);
if (registryPermission == null)
{
return(this.Copy());
}
if (this.IsUnrestricted() || registryPermission.IsUnrestricted())
{
return(new RegistryPermission(PermissionState.Unrestricted));
}
if (this.IsEmpty() && registryPermission.IsEmpty())
{
return(null);
}
RegistryPermission registryPermission2 = (RegistryPermission)this.Copy();
string pathList = registryPermission.GetPathList(RegistryPermissionAccess.Create);
if (pathList != null)
{
registryPermission2.AddPathList(RegistryPermissionAccess.Create, pathList);
}
pathList = registryPermission.GetPathList(RegistryPermissionAccess.Read);
if (pathList != null)
{
registryPermission2.AddPathList(RegistryPermissionAccess.Read, pathList);
}
pathList = registryPermission.GetPathList(RegistryPermissionAccess.Write);
if (pathList != null)
{
registryPermission2.AddPathList(RegistryPermissionAccess.Write, pathList);
}
return(registryPermission2);
}