public bool IsSubsetOf(StrongName2 target)
        {
            // This StrongName2 is a subset of the target if it's public key blob is null no matter what
            if (this.m_publicKeyBlob == null)
                return true;

            // Subsets are always false if the public key blobs do not match
            if (!this.m_publicKeyBlob.Equals( target.m_publicKeyBlob ))
                return false;

            // We use null in strings to represent the "Anything" state.
            // Therefore, the logic to detect an individual subset is:
            //
            // 1. If the this string is null ("Anything" is a subset of any other).
            // 2. If the this string and target string are the same (equality is sufficient for a subset).
            //
            // The logic is reversed here to discover things that are not subsets.
            if (this.m_name != null)
            {
                if (target.m_name == null || !System.Security.Policy.StrongName.CompareNames( target.m_name, this.m_name ))
                    return false;
            }

            if ((Object) this.m_version != null)
            {
                if ((Object) target.m_version == null ||
                    target.m_version.CompareTo( this.m_version ) != 0)
                {
                    return false;
                }
            }

            return true;
        }
 public bool Equals(StrongName2 target)
 {
     if (!target.IsSubsetOf(this))
         return false;
     if (!this.IsSubsetOf(target))
         return false;
     return true;
 }
 public StrongName2 Intersect(StrongName2 target)
 {
     if (target.IsSubsetOf( this ))
         return target.Copy();
     else if (this.IsSubsetOf( target ))
         return this.Copy();
     else
         return null;
 }
        /// <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, or <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. </exception>
        // Token: 0x06002642 RID: 9794 RVA: 0x0008A500 File Offset: 0x00088700
        public override IPermission Intersect(IPermission target)
        {
            if (target == null)
            {
                return(null);
            }
            StrongNameIdentityPermission strongNameIdentityPermission = target as StrongNameIdentityPermission;

            if (strongNameIdentityPermission == null)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[]
                {
                    base.GetType().FullName
                }));
            }
            if (this.m_unrestricted && strongNameIdentityPermission.m_unrestricted)
            {
                return(new StrongNameIdentityPermission(PermissionState.None)
                {
                    m_unrestricted = true
                });
            }
            if (this.m_unrestricted)
            {
                return(strongNameIdentityPermission.Copy());
            }
            if (strongNameIdentityPermission.m_unrestricted)
            {
                return(this.Copy());
            }
            if (this.m_strongNames == null || strongNameIdentityPermission.m_strongNames == null || this.m_strongNames.Length == 0 || strongNameIdentityPermission.m_strongNames.Length == 0)
            {
                return(null);
            }
            List <StrongName2> list = new List <StrongName2>();

            foreach (StrongName2 strongName in this.m_strongNames)
            {
                foreach (StrongName2 target2 in strongNameIdentityPermission.m_strongNames)
                {
                    StrongName2 strongName2 = strongName.Intersect(target2);
                    if (strongName2 != null)
                    {
                        list.Add(strongName2);
                    }
                }
            }
            if (list.Count == 0)
            {
                return(null);
            }
            return(new StrongNameIdentityPermission(PermissionState.None)
            {
                m_strongNames = list.ToArray()
            });
        }
        /// <summary>创建并返回一个权限,该权限是当前权限和指定权限的交集。</summary>
        /// <returns>一个新的权限,表示当前权限与指定权限的交集,或为 null(如果交集为空)。</returns>
        /// <param name="target">要与当前权限相交的权限。它必须与当前权限属于同一类型。</param>
        /// <exception cref="T:System.ArgumentException">
        /// <paramref name="target" /> 参数不是 null,而且与当前权限不是同一类型。</exception>
        public override IPermission Intersect(IPermission target)
        {
            if (target == null)
            {
                return((IPermission)null);
            }
            StrongNameIdentityPermission identityPermission = target as StrongNameIdentityPermission;

            if (identityPermission == null)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", (object)this.GetType().FullName));
            }
            if (this.m_unrestricted && identityPermission.m_unrestricted)
            {
                return (IPermission) new StrongNameIdentityPermission(PermissionState.None)
                       {
                           m_unrestricted = true
                       }
            }
            ;
            if (this.m_unrestricted)
            {
                return(identityPermission.Copy());
            }
            if (identityPermission.m_unrestricted)
            {
                return(this.Copy());
            }
            if (this.m_strongNames == null || identityPermission.m_strongNames == null || (this.m_strongNames.Length == 0 || identityPermission.m_strongNames.Length == 0))
            {
                return((IPermission)null);
            }
            List <StrongName2> strongName2List = new List <StrongName2>();

            foreach (StrongName2 mStrongName1 in this.m_strongNames)
            {
                foreach (StrongName2 mStrongName2 in identityPermission.m_strongNames)
                {
                    StrongName2 strongName2 = mStrongName1.Intersect(mStrongName2);
                    if (strongName2 != null)
                    {
                        strongName2List.Add(strongName2);
                    }
                }
            }
            if (strongName2List.Count == 0)
            {
                return((IPermission)null);
            }
            return((IPermission) new StrongNameIdentityPermission(PermissionState.None)
            {
                m_strongNames = strongName2List.ToArray()
            });
        }
 public StrongName2 Intersect(StrongName2 target)
 {
     if (target.IsSubsetOf(this))
     {
         return(target.Copy());
     }
     if (this.IsSubsetOf(target))
     {
         return(this.Copy());
     }
     return((StrongName2)null);
 }
 public bool Equals(StrongName2 target)
 {
     if (!target.IsSubsetOf(this))
     {
         return(false);
     }
     if (!this.IsSubsetOf(target))
     {
         return(false);
     }
     return(true);
 }
        public override IPermission Intersect(IPermission target)
        {
            if (target == null)
            {
                return(null);
            }
            StrongNameIdentityPermission that = target as StrongNameIdentityPermission;

            if (that == null)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", this.GetType().FullName));
            }
            if (this.m_unrestricted && that.m_unrestricted)
            {
                StrongNameIdentityPermission res = new StrongNameIdentityPermission(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_strongNames == null || that.m_strongNames == null || this.m_strongNames.Length == 0 || that.m_strongNames.Length == 0)
            {
                return(null);
            }
            List <StrongName2> alStrongNames = new List <StrongName2>();

            foreach (StrongName2 snThis in this.m_strongNames)
            {
                foreach (StrongName2 snThat in that.m_strongNames)
                {
                    StrongName2 snInt = (StrongName2)snThis.Intersect(snThat);
                    if (snInt != null)
                    {
                        alStrongNames.Add(snInt);
                    }
                }
            }
            if (alStrongNames.Count == 0)
            {
                return(null);
            }
            StrongNameIdentityPermission result = new StrongNameIdentityPermission(PermissionState.None);

            result.m_strongNames = alStrongNames.ToArray();
            return(result);
        }
        public override void FromXml(SecurityElement e)
        {
            m_unrestricted = false;
            m_strongNames  = null;
            CodeAccessPermission.ValidateElement(e, this);
            String unr = e.Attribute("Unrestricted");

            if (unr != null && String.Compare(unr, "true", StringComparison.OrdinalIgnoreCase) == 0)
            {
                m_unrestricted = true;
                return;
            }
            String             elBlob    = e.Attribute("PublicKeyBlob");
            String             elName    = e.Attribute("Name");
            String             elVersion = e.Attribute("AssemblyVersion");
            StrongName2        sn;
            List <StrongName2> al = new List <StrongName2>();

            if (elBlob != null || elName != null || elVersion != null)
            {
                sn = new StrongName2(
                    (elBlob == null ? null : new StrongNamePublicKeyBlob(elBlob)),
                    elName,
                    (elVersion == null ? null : new Version(elVersion)));
                al.Add(sn);
            }
            ArrayList alChildren = e.Children;

            if (alChildren != null)
            {
                foreach (SecurityElement child in alChildren)
                {
                    elBlob    = child.Attribute("PublicKeyBlob");
                    elName    = child.Attribute("Name");
                    elVersion = child.Attribute("AssemblyVersion");
                    if (elBlob != null || elName != null || elVersion != null)
                    {
                        sn = new StrongName2(
                            (elBlob == null ? null : new StrongNamePublicKeyBlob(elBlob)),
                            elName,
                            (elVersion == null ? null : new Version(elVersion)));
                        al.Add(sn);
                    }
                }
            }
            if (al.Count != 0)
            {
                m_strongNames = al.ToArray();
            }
        }
Exemple #10
0
 public StrongNameIdentityPermission(StrongNamePublicKeyBlob blob, String name, Version version)
 {
     if (blob == null)
     {
         throw new ArgumentNullException("blob");
     }
     if (name != null && name.Equals(""))
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_EmptyStrongName"));
     }
     m_unrestricted   = false;
     m_strongNames    = new StrongName2[1];
     m_strongNames[0] = new StrongName2(blob, name, version);
 }
 public bool IsSubsetOf(StrongName2 target)
 {
     if (this.m_publicKeyBlob == null)
     {
         return(true);
     }
     if (!this.m_publicKeyBlob.Equals(target.m_publicKeyBlob))
     {
         return(false);
     }
     if ((this.m_name != null) && ((target.m_name == null) || !StrongName.CompareNames(target.m_name, this.m_name)))
     {
         return(false);
     }
     return((this.m_version == null) || ((target.m_version != null) && (target.m_version.CompareTo(this.m_version) == 0)));
 }
 public bool IsSubsetOf(StrongName2 target)
 {
     if (this.m_publicKeyBlob == null)
     {
         return true;
     }
     if (!this.m_publicKeyBlob.Equals(target.m_publicKeyBlob))
     {
         return false;
     }
     if ((this.m_name != null) && ((target.m_name == null) || !StrongName.CompareNames(target.m_name, this.m_name)))
     {
         return false;
     }
     return ((this.m_version == null) || ((target.m_version != null) && (target.m_version.CompareTo(this.m_version) == 0)));
 }
        /// <summary>从 XML 编码重新构造具有指定状态的权限。</summary>
        /// <param name="e">用于重新构造权限的 XML 编码。</param>
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="e" /> 参数为 null。</exception>
        /// <exception cref="T:System.ArgumentException">
        /// <paramref name="e" /> 参数不是有效的权限元素。- 或 -<paramref name="e" /> 参数的版本号无效。</exception>
        public override void FromXml(SecurityElement e)
        {
            this.m_unrestricted = false;
            this.m_strongNames  = (StrongName2[])null;
            CodeAccessPermission.ValidateElement(e, (IPermission)this);
            string strA = e.Attribute("Unrestricted");

            if (strA != null && string.Compare(strA, "true", StringComparison.OrdinalIgnoreCase) == 0)
            {
                this.m_unrestricted = true;
            }
            else
            {
                string             publicKey1      = e.Attribute("PublicKeyBlob");
                string             name1           = e.Attribute("Name");
                string             version1        = e.Attribute("AssemblyVersion");
                List <StrongName2> strongName2List = new List <StrongName2>();
                if (publicKey1 != null || name1 != null || version1 != null)
                {
                    StrongName2 strongName2 = new StrongName2(publicKey1 == null ? (StrongNamePublicKeyBlob)null : new StrongNamePublicKeyBlob(publicKey1), name1, version1 == null ? (Version)null : new Version(version1));
                    strongName2List.Add(strongName2);
                }
                ArrayList children = e.Children;
                if (children != null)
                {
                    foreach (SecurityElement securityElement in children)
                    {
                        string name2      = "PublicKeyBlob";
                        string publicKey2 = securityElement.Attribute(name2);
                        string name3      = "Name";
                        string name4      = securityElement.Attribute(name3);
                        string name5      = "AssemblyVersion";
                        string version2   = securityElement.Attribute(name5);
                        if (publicKey2 != null || name4 != null || version2 != null)
                        {
                            StrongName2 strongName2 = new StrongName2(publicKey2 == null ? (StrongNamePublicKeyBlob)null : new StrongNamePublicKeyBlob(publicKey2), name4, version2 == null ? (Version)null : new Version(version2));
                            strongName2List.Add(strongName2);
                        }
                    }
                }
                if (strongName2List.Count == 0)
                {
                    return;
                }
                this.m_strongNames = strongName2List.ToArray();
            }
        }
Exemple #14
0
        public override void FromXml(SecurityElement e)
        {
            this.m_unrestricted = false;
            this.m_strongNames  = null;
            CodeAccessPermission.ValidateElement(e, this);
            string strA = e.Attribute("Unrestricted");

            if ((strA != null) && (string.Compare(strA, "true", StringComparison.OrdinalIgnoreCase) == 0))
            {
                this.m_unrestricted = true;
            }
            else
            {
                StrongName2        name;
                string             publicKey = e.Attribute("PublicKeyBlob");
                string             str3      = e.Attribute("Name");
                string             version   = e.Attribute("AssemblyVersion");
                List <StrongName2> list      = new List <StrongName2>();
                if (((publicKey != null) || (str3 != null)) || (version != null))
                {
                    name = new StrongName2((publicKey == null) ? null : new StrongNamePublicKeyBlob(publicKey), str3, (version == null) ? null : new System.Version(version));
                    list.Add(name);
                }
                ArrayList children = e.Children;
                if (children != null)
                {
                    foreach (SecurityElement element in children)
                    {
                        publicKey = element.Attribute("PublicKeyBlob");
                        str3      = element.Attribute("Name");
                        version   = element.Attribute("AssemblyVersion");
                        if (((publicKey != null) || (str3 != null)) || (version != null))
                        {
                            name = new StrongName2((publicKey == null) ? null : new StrongNamePublicKeyBlob(publicKey), str3, (version == null) ? null : new System.Version(version));
                            list.Add(name);
                        }
                    }
                }
                if (list.Count != 0)
                {
                    this.m_strongNames = list.ToArray();
                }
            }
        }
        /// <summary>Reconstructs a permission with a specified state from an XML encoding.</summary>
        /// <param name="e">The XML encoding to use to reconstruct the permission. </param>
        /// <exception cref="T:System.ArgumentNullException">The <paramref name="e" /> parameter is <see langword="null" />. </exception>
        /// <exception cref="T:System.ArgumentException">The <paramref name="e" /> parameter is not a valid permission element.-or- The <paramref name="e" /> parameter's version number is not valid. </exception>
        // Token: 0x06002644 RID: 9796 RVA: 0x0008A7A8 File Offset: 0x000889A8
        public override void FromXml(SecurityElement e)
        {
            this.m_unrestricted = false;
            this.m_strongNames  = null;
            CodeAccessPermission.ValidateElement(e, this);
            string text = e.Attribute("Unrestricted");

            if (text != null && string.Compare(text, "true", StringComparison.OrdinalIgnoreCase) == 0)
            {
                this.m_unrestricted = true;
                return;
            }
            string             text2 = e.Attribute("PublicKeyBlob");
            string             text3 = e.Attribute("Name");
            string             text4 = e.Attribute("AssemblyVersion");
            List <StrongName2> list  = new List <StrongName2>();

            if (text2 != null || text3 != null || text4 != null)
            {
                StrongName2 item = new StrongName2((text2 == null) ? null : new StrongNamePublicKeyBlob(text2), text3, (text4 == null) ? null : new Version(text4));
                list.Add(item);
            }
            ArrayList children = e.Children;

            if (children != null)
            {
                foreach (object obj in children)
                {
                    SecurityElement securityElement = (SecurityElement)obj;
                    text2 = securityElement.Attribute("PublicKeyBlob");
                    text3 = securityElement.Attribute("Name");
                    text4 = securityElement.Attribute("AssemblyVersion");
                    if (text2 != null || text3 != null || text4 != null)
                    {
                        StrongName2 item = new StrongName2((text2 == null) ? null : new StrongNamePublicKeyBlob(text2), text3, (text4 == null) ? null : new Version(text4));
                        list.Add(item);
                    }
                }
            }
            if (list.Count != 0)
            {
                this.m_strongNames = list.ToArray();
            }
        }
 public override void FromXml(SecurityElement e)
 {
     this.m_unrestricted = false;
     this.m_strongNames = null;
     CodeAccessPermission.ValidateElement(e, this);
     string strA = e.Attribute("Unrestricted");
     if ((strA != null) && (string.Compare(strA, "true", StringComparison.OrdinalIgnoreCase) == 0))
     {
         this.m_unrestricted = true;
     }
     else
     {
         StrongName2 name;
         string publicKey = e.Attribute("PublicKeyBlob");
         string str3 = e.Attribute("Name");
         string version = e.Attribute("AssemblyVersion");
         List<StrongName2> list = new List<StrongName2>();
         if (((publicKey != null) || (str3 != null)) || (version != null))
         {
             name = new StrongName2((publicKey == null) ? null : new StrongNamePublicKeyBlob(publicKey), str3, (version == null) ? null : new System.Version(version));
             list.Add(name);
         }
         ArrayList children = e.Children;
         if (children != null)
         {
             foreach (SecurityElement element in children)
             {
                 publicKey = element.Attribute("PublicKeyBlob");
                 str3 = element.Attribute("Name");
                 version = element.Attribute("AssemblyVersion");
                 if (((publicKey != null) || (str3 != null)) || (version != null))
                 {
                     name = new StrongName2((publicKey == null) ? null : new StrongNamePublicKeyBlob(publicKey), str3, (version == null) ? null : new System.Version(version));
                     list.Add(name);
                 }
             }
         }
         if (list.Count != 0)
         {
             this.m_strongNames = list.ToArray();
         }
     }
 }
        public bool IsSubsetOf(StrongName2 target)
        {
            // This StrongName2 is a subset of the target if it's public key blob is null no matter what
            if (this.m_publicKeyBlob == null)
            {
                return(true);
            }

            // Subsets are always false if the public key blobs do not match
            if (!this.m_publicKeyBlob.Equals(target.m_publicKeyBlob))
            {
                return(false);
            }

            // We use null in strings to represent the "Anything" state.
            // Therefore, the logic to detect an individual subset is:
            //
            // 1. If the this string is null ("Anything" is a subset of any other).
            // 2. If the this string and target string are the same (equality is sufficient for a subset).
            //
            // The logic is reversed here to discover things that are not subsets.
            if (this.m_name != null)
            {
                if (target.m_name == null || !System.Security.Policy.StrongName.CompareNames(target.m_name, this.m_name))
                {
                    return(false);
                }
            }

            if ((Object)this.m_version != null)
            {
                if ((Object)target.m_version == null ||
                    target.m_version.CompareTo(this.m_version) != 0)
                {
                    return(false);
                }
            }

            return(true);
        }
 public override void FromXml(SecurityElement e)
 {
     m_unrestricted = false;
     m_strongNames = null;
     CodeAccessPermission.ValidateElement( e, this );
     String unr = e.Attribute( "Unrestricted" );
     if(unr != null && String.Compare(unr, "true", StringComparison.OrdinalIgnoreCase) == 0)
     {
         m_unrestricted = true;
         return;
     }
     String elBlob = e.Attribute("PublicKeyBlob");
     String elName = e.Attribute("Name");
     String elVersion = e.Attribute("AssemblyVersion");
     StrongName2 sn;
     ArrayList al = new ArrayList();
     if(elBlob != null || elName != null || elVersion != null)
     {
         sn = new StrongName2(
                             (elBlob == null ? null : new StrongNamePublicKeyBlob(elBlob)), 
                             elName, 
                             (elVersion == null ? null : new Version(elVersion)));
         al.Add(sn);
     }
     ArrayList alChildren = e.Children;
     if(alChildren != null)
     {
         foreach(SecurityElement child in alChildren)
         {
             elBlob = child.Attribute("PublicKeyBlob");
             elName = child.Attribute("Name");
             elVersion = child.Attribute("AssemblyVersion");
             if(elBlob != null || elName != null || elVersion != null)
             {
                 sn = new StrongName2(
                                     (elBlob == null ? null : new StrongNamePublicKeyBlob(elBlob)), 
                                     elName, 
                                     (elVersion == null ? null : new Version(elVersion)));
                 al.Add(sn);
             }
         }
     }
     if(al.Count != 0)
         m_strongNames = (StrongName2[])al.ToArray(typeof(StrongName2));
 }
 public StrongNameIdentityPermission( StrongNamePublicKeyBlob blob, String name, Version version )
 {
     if (blob == null)
         throw new ArgumentNullException( "blob" );
     if (name != null && name.Equals( "" ))
         throw new ArgumentException( Environment.GetResourceString( "Argument_EmptyStrongName" ) );      
     m_unrestricted = false;
     m_strongNames = new StrongName2[1];
     m_strongNames[0] = new StrongName2(blob, name, version);
 }
 public bool IsSubsetOf(StrongName2 target)
 {
     return(this.m_publicKeyBlob == null || this.m_publicKeyBlob.Equals(target.m_publicKeyBlob) && (this.m_name == null || target.m_name != null && StrongName.CompareNames(target.m_name, this.m_name)) && (this.m_version == null || target.m_version != null && target.m_version.CompareTo(this.m_version) == 0));
 }
 public bool Equals(StrongName2 target)
 {
     return(target.IsSubsetOf(this) && this.IsSubsetOf(target));
 }