Example #1
0
 /// <summary> An AttributeSource that uses the same attributes as the supplied one.</summary>
 public AttributeSource(AttributeSource input)
 {
     if (input == null)
     {
         throw new System.ArgumentException("input AttributeSource must not be null");
     }
     this.attributes     = input.attributes;
     this.attributeImpls = input.attributeImpls;
     this.currentState   = input.currentState;
     this.factory        = input.factory;
 }
Example #2
0
        public override bool Equals(System.Object obj)
        {
            if (obj == this)
            {
                return(true);
            }

            if (obj is AttributeSource)
            {
                AttributeSource other = (AttributeSource)obj;

                if (HasAttributes)
                {
                    if (!other.HasAttributes)
                    {
                        return(false);
                    }

                    if (this.attributeImpls.Count != other.attributeImpls.Count)
                    {
                        return(false);
                    }

                    // it is only equal if all attribute impls are the same in the same order
                    var thisState  = this.GetCurrentState();
                    var otherState = other.GetCurrentState();
                    while (thisState != null && otherState != null)
                    {
                        if (otherState.attribute.GetType() != thisState.attribute.GetType() || !otherState.attribute.Equals(thisState.attribute))
                        {
                            return(false);
                        }
                        thisState  = thisState.next;
                        otherState = otherState.next;
                    }
                    return(true);
                }
                else
                {
                    return(!other.HasAttributes);
                }
            }
            else
            {
                return(false);
            }
        }