Ejemplo n.º 1
0
        /// <summary>
        /// Check if the selectors of the css blocks is the same.
        /// </summary>
        /// <param name="other">the other block to compare to</param>
        /// <returns>true - the selectors on blocks are the same, false - otherwise</returns>
        public bool EqualsSelector(CssBlock other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            if (other.Hover != Hover)
            {
                return(false);
            }
            if (other._selectors == null && _selectors != null)
            {
                return(false);
            }
            if (other._selectors != null && _selectors == null)
            {
                return(false);
            }

            if (other._selectors != null && _selectors != null)
            {
                if (!Equals(other._selectors.Count, _selectors.Count))
                {
                    return(false);
                }

                for (int i = 0; i < _selectors.Count; i++)
                {
                    if (!Equals(other._selectors[i].Class, _selectors[i].Class))
                    {
                        return(false);
                    }
                    if (!Equals(other._selectors[i].DirectParent, _selectors[i].DirectParent))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Check if the two css blocks are the same (same class, selectors and properties).
        /// </summary>
        /// <param name="other">the other block to compare to</param>
        /// <returns>true - the two blocks are the same, false - otherwise</returns>
        public bool Equals(CssBlock other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }
            if (!Equals(other._class, _class))
            {
                return(false);
            }

            if (!Equals(other._properties.Count, _properties.Count))
            {
                return(false);
            }

            foreach (var property in _properties)
            {
                if (!other._properties.ContainsKey(property.Key))
                {
                    return(false);
                }
                if (!Equals(other._properties[property.Key], property.Value))
                {
                    return(false);
                }
            }

            if (!EqualsSelector(other))
            {
                return(false);
            }

            return(true);
        }