/// <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"); }
/// <summary>Creates and returns a permission that is the intersection of the current permission and the specified permission.</summary> /// <param name="target">A permission to intersect with the current permission. It must be of the same type as the current permission. </param> /// <returns>A new permission that represents the intersection of the current permission and the specified permission. This new permission is <see langword="null" /> if the intersection is empty.</returns> /// <exception cref="T:System.ArgumentException">The <paramref name="target" /> parameter is not <see langword="null" /> and is not of the same type as the current permission. -or-The Url property is not a valid URL.</exception> // Token: 0x06002671 RID: 9841 RVA: 0x0008B318 File Offset: 0x00089518 public override IPermission Intersect(IPermission target) { if (target == null) { return(null); } UrlIdentityPermission urlIdentityPermission = target as UrlIdentityPermission; if (urlIdentityPermission == null) { throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[] { base.GetType().FullName })); } if (this.m_unrestricted && urlIdentityPermission.m_unrestricted) { return(new UrlIdentityPermission(PermissionState.None) { m_unrestricted = true }); } if (this.m_unrestricted) { return(urlIdentityPermission.Copy()); } if (urlIdentityPermission.m_unrestricted) { return(this.Copy()); } if (this.m_urls == null || urlIdentityPermission.m_urls == null || this.m_urls.Length == 0 || urlIdentityPermission.m_urls.Length == 0) { return(null); } List <URLString> list = new List <URLString>(); foreach (URLString urlstring in this.m_urls) { foreach (URLString operand in urlIdentityPermission.m_urls) { URLString urlstring2 = (URLString)urlstring.Intersect(operand); if (urlstring2 != null) { list.Add(urlstring2); } } } if (list.Count == 0) { return(null); } return(new UrlIdentityPermission(PermissionState.None) { m_urls = list.ToArray() }); }
/// <summary>创建并返回一个权限,该权限是当前权限和指定权限的交集。</summary> /// <returns>一个新权限,它表示当前权限与指定权限的交集。如果交集为空,则此新权限为 null。</returns> /// <param name="target">要与当前权限相交的权限。它必须与当前权限属于同一类型。</param> /// <exception cref="T:System.ArgumentException"> /// <paramref name="target" /> 参数不是 null,而且与当前权限不是同一类型。- 或 -Url 属性不是有效的 URL。</exception> public override IPermission Intersect(IPermission target) { if (target == null) { return((IPermission)null); } UrlIdentityPermission identityPermission = target as UrlIdentityPermission; if (identityPermission == null) { throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", (object)this.GetType().FullName)); } if (this.m_unrestricted && identityPermission.m_unrestricted) { return (IPermission) new UrlIdentityPermission(PermissionState.None) { m_unrestricted = true } } ; if (this.m_unrestricted) { return(identityPermission.Copy()); } if (identityPermission.m_unrestricted) { return(this.Copy()); } if (this.m_urls == null || identityPermission.m_urls == null || (this.m_urls.Length == 0 || identityPermission.m_urls.Length == 0)) { return((IPermission)null); } List <URLString> urlStringList = new List <URLString>(); foreach (URLString mUrl1 in this.m_urls) { foreach (URLString mUrl2 in identityPermission.m_urls) { URLString urlString = (URLString)mUrl1.Intersect((SiteString)mUrl2); if (urlString != null) { urlStringList.Add(urlString); } } } if (urlStringList.Count == 0) { return((IPermission)null); } return((IPermission) new UrlIdentityPermission(PermissionState.None) { m_urls = urlStringList.ToArray() }); }
public void PermissionState_None () { UrlIdentityPermission uip = new UrlIdentityPermission (PermissionState.None); // that cause a NullReferenceException before 2.0 Assert.AreEqual (String.Empty, uip.Url, "Url"); SecurityElement se = uip.ToXml (); // only class and version are present Assert.AreEqual (2, se.Attributes.Count, "Xml-Attributes"); Assert.IsNull (se.Children, "Xml-Children"); UrlIdentityPermission copy = (UrlIdentityPermission)uip.Copy (); Assert.IsFalse (Object.ReferenceEquals (uip, copy), "ReferenceEquals"); }
public override IPermission Intersect(IPermission target) { if (target == null) { return(null); } UrlIdentityPermission permission = target as UrlIdentityPermission; if (permission == null) { throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[] { base.GetType().FullName })); } if (this.m_unrestricted && permission.m_unrestricted) { return(new UrlIdentityPermission(PermissionState.None) { m_unrestricted = true }); } if (this.m_unrestricted) { return(permission.Copy()); } if (permission.m_unrestricted) { return(this.Copy()); } if (((this.m_urls == null) || (permission.m_urls == null)) || ((this.m_urls.Length == 0) || (permission.m_urls.Length == 0))) { return(null); } List <URLString> list = new List <URLString>(); foreach (URLString str in this.m_urls) { foreach (URLString str2 in permission.m_urls) { URLString item = (URLString)str.Intersect(str2); if (item != null) { list.Add(item); } } } if (list.Count == 0) { return(null); } return(new UrlIdentityPermission(PermissionState.None) { m_urls = list.ToArray() }); }
public override IPermission Intersect(IPermission target) { if (target == null) { return(null); } UrlIdentityPermission that = target as UrlIdentityPermission; if (that == null) { throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", this.GetType().FullName)); } if (this.m_unrestricted && that.m_unrestricted) { UrlIdentityPermission res = new UrlIdentityPermission(PermissionState.None); res.m_unrestricted = true; return(res); } if (this.m_unrestricted) { return(that.Copy()); } if (that.m_unrestricted) { return(this.Copy()); } if (this.m_urls == null || that.m_urls == null || this.m_urls.Length == 0 || that.m_urls.Length == 0) { return(null); } List <URLString> alUrls = new List <URLString>(); foreach (URLString usThis in this.m_urls) { foreach (URLString usThat in that.m_urls) { URLString usInt = (URLString)usThis.Intersect(usThat); if (usInt != null) { alUrls.Add(usInt); } } } if (alUrls.Count == 0) { return(null); } UrlIdentityPermission result = new UrlIdentityPermission(PermissionState.None); result.m_urls = alUrls.ToArray(); return(result); }
/// <summary>Creates and returns a permission that is the intersection of the current permission and the specified permission.</summary> /// <returns>A new permission that represents the intersection of the current permission and the specified permission. This new permission is null if the intersection is empty.</returns> /// <param name="target">A permission to intersect 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 Url property is not a valid URL.</exception> public override IPermission Intersect(IPermission target) { UrlIdentityPermission urlIdentityPermission = this.Cast(target); if (urlIdentityPermission == null || this.IsEmpty()) { return(null); } if (!this.Match(urlIdentityPermission.url)) { return(null); } if (this.url.Length > urlIdentityPermission.url.Length) { return(this.Copy()); } return(urlIdentityPermission.Copy()); }
public override IPermission Intersect(IPermission target) { // if one permission is null (object or url) then there's no intersection // if both are null then intersection is null UrlIdentityPermission uip = Cast(target); if ((uip == null) || (IsEmpty())) { return(null); } if (Match(uip.url)) { // longest form is the intersection if (url.Length > uip.url.Length) { return(Copy()); } else { return(uip.Copy()); } } return(null); }
public void Copy_None () { UrlIdentityPermission uip = new UrlIdentityPermission (PermissionState.None); UrlIdentityPermission copy = (UrlIdentityPermission)uip.Copy (); }
public void Copy () { UrlIdentityPermission uip = new UrlIdentityPermission (PermissionState.None); foreach (string s in GoodUrls) { uip.Url = s; UrlIdentityPermission copy = (UrlIdentityPermission)uip.Copy (); // Fx 1.0/1.1 adds a '/' at the end, while 2.0 keeps the original format // so we only compare the start of the url Assert.AreEqual (uip.Url, copy.Url, "Url"); } }
public override IPermission Union(IPermission target) { if (target == null) { if ((this.m_urls == null || this.m_urls.Length == 0) && !this.m_unrestricted) { return(null); } return(this.Copy()); } UrlIdentityPermission that = target as UrlIdentityPermission; if (that == null) { throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", this.GetType().FullName)); } if (this.m_unrestricted || that.m_unrestricted) { UrlIdentityPermission res = new UrlIdentityPermission(PermissionState.None); res.m_unrestricted = true; return(res); } if (this.m_urls == null || this.m_urls.Length == 0) { if (that.m_urls == null || that.m_urls.Length == 0) { return(null); } return(that.Copy()); } if (that.m_urls == null || that.m_urls.Length == 0) { return(this.Copy()); } List <URLString> alUrls = new List <URLString>(); foreach (URLString usThis in this.m_urls) { alUrls.Add(usThis); } foreach (URLString usThat in that.m_urls) { bool bDupe = false; foreach (URLString us in alUrls) { if (usThat.Equals(us)) { bDupe = true; break; } } if (!bDupe) { alUrls.Add(usThat); } } UrlIdentityPermission result = new UrlIdentityPermission(PermissionState.None); result.m_urls = alUrls.ToArray(); return(result); }
/// <summary>Creates a permission that is the union of the current permission and the specified permission.</summary> /// <param name="target">A permission to combine with the current permission. It must be of the same type as the current permission. </param> /// <returns>A new permission that represents the union of the current permission and the specified permission.</returns> /// <exception cref="T:System.ArgumentException">The <paramref name="target" /> parameter is not <see langword="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> // Token: 0x06002672 RID: 9842 RVA: 0x0008B440 File Offset: 0x00089640 public override IPermission Union(IPermission target) { if (target == null) { if ((this.m_urls == null || this.m_urls.Length == 0) && !this.m_unrestricted) { return(null); } return(this.Copy()); } else { UrlIdentityPermission urlIdentityPermission = target as UrlIdentityPermission; if (urlIdentityPermission == null) { throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[] { base.GetType().FullName })); } if (this.m_unrestricted || urlIdentityPermission.m_unrestricted) { return(new UrlIdentityPermission(PermissionState.None) { m_unrestricted = true }); } if (this.m_urls == null || this.m_urls.Length == 0) { if (urlIdentityPermission.m_urls == null || urlIdentityPermission.m_urls.Length == 0) { return(null); } return(urlIdentityPermission.Copy()); } else { if (urlIdentityPermission.m_urls == null || urlIdentityPermission.m_urls.Length == 0) { return(this.Copy()); } List <URLString> list = new List <URLString>(); foreach (URLString item in this.m_urls) { list.Add(item); } foreach (URLString urlstring in urlIdentityPermission.m_urls) { bool flag = false; foreach (URLString url in list) { if (urlstring.Equals(url)) { flag = true; break; } } if (!flag) { list.Add(urlstring); } } return(new UrlIdentityPermission(PermissionState.None) { m_urls = list.ToArray() }); } } }
public override IPermission Union(IPermission target) { if (target == null) { if (((this.m_urls == null) || (this.m_urls.Length == 0)) && !this.m_unrestricted) { return(null); } return(this.Copy()); } UrlIdentityPermission permission = target as UrlIdentityPermission; if (permission == null) { throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[] { base.GetType().FullName })); } if (this.m_unrestricted || permission.m_unrestricted) { return(new UrlIdentityPermission(PermissionState.None) { m_unrestricted = true }); } if ((this.m_urls == null) || (this.m_urls.Length == 0)) { if ((permission.m_urls != null) && (permission.m_urls.Length != 0)) { return(permission.Copy()); } return(null); } if ((permission.m_urls == null) || (permission.m_urls.Length == 0)) { return(this.Copy()); } List <URLString> list = new List <URLString>(); foreach (URLString str in this.m_urls) { list.Add(str); } foreach (URLString str2 in permission.m_urls) { bool flag = false; foreach (URLString str3 in list) { if (str2.Equals(str3)) { flag = true; break; } } if (!flag) { list.Add(str2); } } return(new UrlIdentityPermission(PermissionState.None) { m_urls = list.ToArray() }); }
/// <summary>创建一个权限,该权限是当前权限与指定权限的并集。</summary> /// <returns>一个新权限,它表示当前权限与指定权限的并集。</returns> /// <param name="target">将与当前权限合并的权限。它必须与当前权限属于同一类型。</param> /// <exception cref="T:System.ArgumentException"> /// <paramref name="target" /> 参数不是 null,而且与当前权限不是同一类型。- 或 -<see cref="P:System.Security.Permissions.UrlIdentityPermission.Url" /> 属性不是有效的 URL。- 或 -两个权限不相等,而且其中一个不是另一个的子集。</exception> public override IPermission Union(IPermission target) { if (target == null) { if ((this.m_urls == null || this.m_urls.Length == 0) && !this.m_unrestricted) { return((IPermission)null); } return(this.Copy()); } UrlIdentityPermission identityPermission = target as UrlIdentityPermission; if (identityPermission == null) { throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", (object)this.GetType().FullName)); } if (this.m_unrestricted || identityPermission.m_unrestricted) { return (IPermission) new UrlIdentityPermission(PermissionState.None) { m_unrestricted = true } } ; if (this.m_urls == null || this.m_urls.Length == 0) { if (identityPermission.m_urls == null || identityPermission.m_urls.Length == 0) { return((IPermission)null); } return(identityPermission.Copy()); } if (identityPermission.m_urls == null || identityPermission.m_urls.Length == 0) { return(this.Copy()); } List <URLString> urlStringList = new List <URLString>(); foreach (URLString mUrl in this.m_urls) { urlStringList.Add(mUrl); } foreach (URLString mUrl in identityPermission.m_urls) { bool flag = false; foreach (URLString url in urlStringList) { if (mUrl.Equals(url)) { flag = true; break; } } if (!flag) { urlStringList.Add(mUrl); } } return((IPermission) new UrlIdentityPermission(PermissionState.None) { m_urls = urlStringList.ToArray() }); }