/// <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="target">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="target" /> parameter is not null and is not of the same type as the current permission. -or-The <see cref="P:System.Security.Permissions.UrlIdentityPermission.Url" /> property is not a valid URL.-or-The two permissions are not equal and one is not a subset of the other.</exception> public override IPermission Union(IPermission target) { UrlIdentityPermission urlIdentityPermission = this.Cast(target); if (urlIdentityPermission == null) { return(this.Copy()); } if (this.IsEmpty() && urlIdentityPermission.IsEmpty()) { return(null); } if (urlIdentityPermission.IsEmpty()) { return(this.Copy()); } if (this.IsEmpty()) { return(urlIdentityPermission.Copy()); } if (!this.Match(urlIdentityPermission.url)) { throw new ArgumentException(Locale.GetText("Cannot union two different urls."), "target"); } if (this.url.Length < urlIdentityPermission.url.Length) { return(this.Copy()); } return(urlIdentityPermission.Copy()); }
public override IPermission Union(IPermission target) { UrlIdentityPermission uip = Cast(target); if (uip == null) { return(Copy()); } if (IsEmpty() && uip.IsEmpty()) { return(null); } if (uip.IsEmpty()) { return(Copy()); } if (IsEmpty()) { return(uip.Copy()); } if (Match(uip.url)) { // shortest form is the union if (url.Length < uip.url.Length) { return(Copy()); } else { return(uip.Copy()); } } throw new ArgumentException(Locale.GetText( "Cannot union two different urls."), "target"); }