ConvertSecurityElementFactories() private method

private ConvertSecurityElementFactories ( ) : void
return void
Example #1
0
        public bool Equal( SecurityElement other )
        {
            if (other == null)
                return false;
        
            // Check if the tags are the same
            if (!String.Equals(m_strTag, other.m_strTag))
                return false;

            // Check if the text is the same
            if (!String.Equals(m_strText, other.m_strText))
                return false;

            // Check if the attributes are the same and appear in the same
            // order.
            
            // Maybe we can get away by only checking the number of attributes
            if (m_lAttributes == null || other.m_lAttributes == null)
            {
                if (m_lAttributes != other.m_lAttributes)
                    return false;
            }
            else 
            {                
                int iMax = m_lAttributes.Count;
                Debug.Assert( iMax % 2 == 0, "Odd number of strings means the attr/value pairs were not added correctly" );

                if (iMax != other.m_lAttributes.Count)
                    return false;
                          
                for (int i = 0; i < iMax; i++)
                {
                    String lhs = (String)m_lAttributes[i];
                    String rhs = (String)other.m_lAttributes[i];
                    
                    if (!String.Equals(lhs, rhs))
                        return false;
                }
            }

            // Finally we must check the child and make sure they are
            // equal and in the same order
            
            // Maybe we can get away by only checking the number of children
            if (m_lChildren == null || other.m_lChildren == null) 
            {
                if (m_lChildren != other.m_lChildren)
                    return false;
            } 
            else 
            {
                if (m_lChildren.Count != other.m_lChildren.Count)
                    return false;

                this.ConvertSecurityElementFactories();
                other.ConvertSecurityElementFactories();

                // Okay, we'll need to go through each one of them
                IEnumerator lhs = m_lChildren.GetEnumerator();
                IEnumerator rhs = other.m_lChildren.GetEnumerator();

                SecurityElement e1, e2;
                while (lhs.MoveNext())
                {
                    rhs.MoveNext();
                    e1 = (SecurityElement)lhs.Current;
                    e2 = (SecurityElement)rhs.Current;       
                    if (e1 == null || !e1.Equal(e2))                
                        return false;
                }
            }
            return true;
        }
 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;
 }