/// <summary>Determines whether the current permission is a subset of the specified permission.</summary> /// <returns>true if the current permission is a subset of the specified permission; otherwise, false.</returns> /// <param name="target">A permission that is to be tested for the subset relationship. This permission 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. </exception> public override bool IsSubsetOf(IPermission target) { StrongNameIdentityPermission strongNameIdentityPermission = this.Cast(target); if (strongNameIdentityPermission == null) { return(this.IsEmpty()); } if (this.IsEmpty()) { return(true); } if (this.IsUnrestricted()) { return(strongNameIdentityPermission.IsUnrestricted()); } if (strongNameIdentityPermission.IsUnrestricted()) { return(true); } foreach (object obj in this._list) { StrongNameIdentityPermission.SNIP snip = (StrongNameIdentityPermission.SNIP)obj; foreach (object obj2 in strongNameIdentityPermission._list) { StrongNameIdentityPermission.SNIP target2 = (StrongNameIdentityPermission.SNIP)obj2; if (!snip.IsSubsetOf(target2)) { return(false); } } } return(true); }
internal StrongNameIdentityPermission(StrongNameIdentityPermission snip) { this._state = snip._state; this._list = new ArrayList(snip._list.Count); foreach (object obj in snip._list) { StrongNameIdentityPermission.SNIP snip2 = (StrongNameIdentityPermission.SNIP)obj; this._list.Add(new StrongNameIdentityPermission.SNIP(snip2.PublicKey, snip2.Name, snip2.AssemblyVersion)); } }
private bool Contains(StrongNameIdentityPermission.SNIP snip) { foreach (object obj in this._list) { StrongNameIdentityPermission.SNIP snip2 = (StrongNameIdentityPermission.SNIP)obj; bool flag = (snip2.PublicKey == null && snip.PublicKey == null) || (snip2.PublicKey != null && snip2.PublicKey.Equals(snip.PublicKey)); bool flag2 = snip2.IsNameSubsetOf(snip.Name); bool flag3 = (snip2.AssemblyVersion == null && snip.AssemblyVersion == null) || (snip2.AssemblyVersion != null && snip2.AssemblyVersion.Equals(snip.AssemblyVersion)); if (flag && flag2 && flag3) { return(true); } } return(false); }
private void ToSecurityElement(SecurityElement se, StrongNameIdentityPermission.SNIP snip) { if (snip.PublicKey != null) { se.AddAttribute("PublicKeyBlob", snip.PublicKey.ToString()); } if (snip.Name != null) { se.AddAttribute("Name", snip.Name); } if (snip.AssemblyVersion != null) { se.AddAttribute("AssemblyVersion", snip.AssemblyVersion.ToString()); } }
/// <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 two permissions are not equal and one is a subset of the other.</exception> public override IPermission Union(IPermission target) { StrongNameIdentityPermission strongNameIdentityPermission = this.Cast(target); if (strongNameIdentityPermission == null || strongNameIdentityPermission.IsEmpty()) { return(this.Copy()); } if (this.IsEmpty()) { return(strongNameIdentityPermission.Copy()); } StrongNameIdentityPermission strongNameIdentityPermission2 = (StrongNameIdentityPermission)this.Copy(); foreach (object obj in strongNameIdentityPermission._list) { StrongNameIdentityPermission.SNIP snip = (StrongNameIdentityPermission.SNIP)obj; if (!this.IsEmpty(snip) && !this.Contains(snip)) { strongNameIdentityPermission2._list.Add(snip); } } return(strongNameIdentityPermission2); }
/// <summary>Creates an XML encoding of the permission and its current state.</summary> /// <returns>An XML encoding of the permission, including any state information.</returns> public override SecurityElement ToXml() { SecurityElement securityElement = base.Element(1); if (this._list.Count > 1) { foreach (object obj in this._list) { StrongNameIdentityPermission.SNIP snip = (StrongNameIdentityPermission.SNIP)obj; SecurityElement securityElement2 = new SecurityElement("StrongName"); this.ToSecurityElement(securityElement2, snip); securityElement.AddChild(securityElement2); } } else if (this._list.Count == 1) { StrongNameIdentityPermission.SNIP snip2 = (StrongNameIdentityPermission.SNIP) this._list[0]; if (!this.IsEmpty(snip2)) { this.ToSecurityElement(securityElement, snip2); } } return(securityElement); }
internal bool IsSubsetOf(StrongNameIdentityPermission.SNIP target) { return((this.PublicKey != null && this.PublicKey.Equals(target.PublicKey)) || (this.IsNameSubsetOf(target.Name) && (!(this.AssemblyVersion != null) || this.AssemblyVersion.Equals(target.AssemblyVersion)) && this.PublicKey == null && target.PublicKey == null)); }
private bool IsEmpty(StrongNameIdentityPermission.SNIP snip) { return(this.PublicKey == null && (this.Name == null || this.Name.Length <= 0) && (this.Version == null || StrongNameIdentityPermission.defaultVersion.Equals(this.Version))); }