Equal() public method

public Equal ( SecurityElement other ) : bool
other SecurityElement
return bool
Exemplo n.º 1
0
 /// <summary>比较两个 XML 元素对象,确定它们是否相等。</summary>
 /// <returns>如果当前 XML 元素中的标记、特性名和值、子元素以及文本字段与 <paramref name="other" /> 参数中的对等部分相同,则为 true;否则为 false。</returns>
 /// <param name="other">要与当前 XML 元素对象进行比较的 XML 元素对象。</param>
 public bool Equal(SecurityElement other)
 {
     if (other == null || !string.Equals(this.m_strTag, other.m_strTag) || !string.Equals(this.m_strText, other.m_strText))
     {
         return(false);
     }
     if (this.m_lAttributes == null || other.m_lAttributes == null)
     {
         if (this.m_lAttributes != other.m_lAttributes)
         {
             return(false);
         }
     }
     else
     {
         int count = this.m_lAttributes.Count;
         if (count != other.m_lAttributes.Count)
         {
             return(false);
         }
         for (int index = 0; index < count; ++index)
         {
             if (!string.Equals((string)this.m_lAttributes[index], (string)other.m_lAttributes[index]))
             {
                 return(false);
             }
         }
     }
     if (this.m_lChildren == null || other.m_lChildren == null)
     {
         if (this.m_lChildren != other.m_lChildren)
         {
             return(false);
         }
     }
     else
     {
         if (this.m_lChildren.Count != other.m_lChildren.Count)
         {
             return(false);
         }
         this.ConvertSecurityElementFactories();
         other.ConvertSecurityElementFactories();
         IEnumerator enumerator1 = this.m_lChildren.GetEnumerator();
         IEnumerator enumerator2 = other.m_lChildren.GetEnumerator();
         while (enumerator1.MoveNext())
         {
             enumerator2.MoveNext();
             SecurityElement securityElement = (SecurityElement)enumerator1.Current;
             SecurityElement other1          = (SecurityElement)enumerator2.Current;
             if (securityElement == null || !securityElement.Equal(other1))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Exemplo n.º 2
0
 public bool Equal(SecurityElement other)
 {
     if (other == null)
     {
         return(false);
     }
     if (!string.Equals(this.m_strTag, other.m_strTag))
     {
         return(false);
     }
     if (!string.Equals(this.m_strText, other.m_strText))
     {
         return(false);
     }
     if ((this.m_lAttributes == null) || (other.m_lAttributes == null))
     {
         if (this.m_lAttributes != other.m_lAttributes)
         {
             return(false);
         }
     }
     else
     {
         int count = this.m_lAttributes.Count;
         if (count != other.m_lAttributes.Count)
         {
             return(false);
         }
         for (int i = 0; i < count; i++)
         {
             string a = (string)this.m_lAttributes[i];
             string b = (string)other.m_lAttributes[i];
             if (!string.Equals(a, b))
             {
                 return(false);
             }
         }
     }
     if ((this.m_lChildren == null) || (other.m_lChildren == null))
     {
         if (this.m_lChildren != other.m_lChildren)
         {
             return(false);
         }
     }
     else
     {
         if (this.m_lChildren.Count != other.m_lChildren.Count)
         {
             return(false);
         }
         this.ConvertSecurityElementFactories();
         other.ConvertSecurityElementFactories();
         IEnumerator enumerator  = this.m_lChildren.GetEnumerator();
         IEnumerator enumerator2 = other.m_lChildren.GetEnumerator();
         while (enumerator.MoveNext())
         {
             enumerator2.MoveNext();
             SecurityElement current  = (SecurityElement)enumerator.Current;
             SecurityElement element2 = (SecurityElement)enumerator2.Current;
             if ((current == null) || !current.Equal(element2))
             {
                 return(false);
             }
         }
     }
     return(true);
 }