public override IPermission Union(IPermission target) { SiteIdentityPermission sip = Cast(target); if ((sip == null) || sip.IsEmpty()) { return(Copy()); } if (IsEmpty()) { return(sip.Copy()); } if (Match(sip._site)) { string s = ((_site.Length < sip._site.Length) ? _site : sip._site); return(new SiteIdentityPermission(s)); } #if NET_2_0 throw new ArgumentException(Locale.GetText( "Cannot union two different sites."), "target"); #else return(null); #endif }
/// <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 permissions are not equal and one is not a subset of the other.</exception> public override IPermission Union(IPermission target) { SiteIdentityPermission siteIdentityPermission = this.Cast(target); if (siteIdentityPermission == null || siteIdentityPermission.IsEmpty()) { return(this.Copy()); } if (this.IsEmpty()) { return(siteIdentityPermission.Copy()); } if (this.Match(siteIdentityPermission._site)) { string site = (this._site.Length >= siteIdentityPermission._site.Length) ? siteIdentityPermission._site : this._site; return(new SiteIdentityPermission(site)); } throw new ArgumentException(Locale.GetText("Cannot union two different sites."), "target"); }