Пример #1
0
        public override bool Equals(Object o)
        {
            HashMembershipCondition that = (o as HashMembershipCondition);

            if (that != null)
            {
                if (this.m_hashAlg == null && this.m_element != null)
                {
                    this.ParseHashAlgorithm();
                }
                if (that.m_hashAlg == null && that.m_element != null)
                {
                    that.ParseHashAlgorithm();
                }

                if (this.m_hashAlg != null && that.m_hashAlg != null &&
                    this.m_hashAlg.GetType() == that.m_hashAlg.GetType())
                {
                    if (this.m_value == null && this.m_element != null)
                    {
                        this.ParseHashValue();
                    }
                    if (that.m_value == null && that.m_element != null)
                    {
                        that.ParseHashValue();
                    }

                    if (this.m_value.Length != that.m_value.Length)
                    {
                        return(false);
                    }

                    for (int i = 0; i < m_value.Length; i++)
                    {
                        if (this.m_value[i] != that.m_value[i])
                        {
                            return(false);
                        }
                    }
                    return(true);
                }
            }
            return(false);
        }
Пример #2
0
        public override bool Equals(object o)
        {
            HashMembershipCondition condition = o as HashMembershipCondition;

            if (condition != null)
            {
                if ((this.m_hashAlg == null) && (this.m_element != null))
                {
                    this.ParseHashAlgorithm();
                }
                if ((condition.m_hashAlg == null) && (condition.m_element != null))
                {
                    condition.ParseHashAlgorithm();
                }
                if (((this.m_hashAlg != null) && (condition.m_hashAlg != null)) && (this.m_hashAlg.GetType() == condition.m_hashAlg.GetType()))
                {
                    if ((this.m_value == null) && (this.m_element != null))
                    {
                        this.ParseHashValue();
                    }
                    if ((condition.m_value == null) && (condition.m_element != null))
                    {
                        condition.ParseHashValue();
                    }
                    if (this.m_value.Length != condition.m_value.Length)
                    {
                        return(false);
                    }
                    for (int i = 0; i < this.m_value.Length; i++)
                    {
                        if (this.m_value[i] != condition.m_value[i])
                        {
                            return(false);
                        }
                    }
                    return(true);
                }
            }
            return(false);
        }
        /// <summary>确定指定对象中的 <see cref="P:System.Security.Policy.HashMembershipCondition.HashValue" /> 和 <see cref="P:System.Security.Policy.HashMembershipCondition.HashAlgorithm" /> 是否等效于包含在当前 <see cref="T:System.Security.Policy.HashMembershipCondition" /> 中的 <see cref="P:System.Security.Policy.HashMembershipCondition.HashValue" /> 和 <see cref="P:System.Security.Policy.HashMembershipCondition.HashAlgorithm" />。</summary>
        /// <returns>如果指定对象中的 <see cref="P:System.Security.Policy.HashMembershipCondition.HashValue" /> 和 <see cref="P:System.Security.Policy.HashMembershipCondition.HashAlgorithm" /> 等效于包含在当前 <see cref="T:System.Security.Policy.HashMembershipCondition" /> 中的 <see cref="P:System.Security.Policy.HashMembershipCondition.HashValue" /> 和 <see cref="P:System.Security.Policy.HashMembershipCondition.HashAlgorithm" />,则为 true;否则为 false。</returns>
        /// <param name="o">与当前的 <see cref="T:System.Security.Policy.HashMembershipCondition" /> 比较的对象。</param>
        /// <PermissionSet>
        ///   <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
        /// </PermissionSet>
        public override bool Equals(object o)
        {
            HashMembershipCondition membershipCondition = o as HashMembershipCondition;

            if (membershipCondition != null)
            {
                if (this.m_hashAlg == null && this.m_element != null)
                {
                    this.ParseHashAlgorithm();
                }
                if (membershipCondition.m_hashAlg == null && membershipCondition.m_element != null)
                {
                    membershipCondition.ParseHashAlgorithm();
                }
                if (this.m_hashAlg != null && membershipCondition.m_hashAlg != null && this.m_hashAlg.GetType() == membershipCondition.m_hashAlg.GetType())
                {
                    if (this.m_value == null && this.m_element != null)
                    {
                        this.ParseHashValue();
                    }
                    if (membershipCondition.m_value == null && membershipCondition.m_element != null)
                    {
                        membershipCondition.ParseHashValue();
                    }
                    if (this.m_value.Length != membershipCondition.m_value.Length)
                    {
                        return(false);
                    }
                    for (int index = 0; index < this.m_value.Length; ++index)
                    {
                        if ((int)this.m_value[index] != (int)membershipCondition.m_value[index])
                        {
                            return(false);
                        }
                    }
                    return(true);
                }
            }
            return(false);
        }