Beispiel #1
0
        /// <summary>
        /// Returns true if this value is equivalent to the other, false otherwise.
        /// </summary>
        /// <param name="other">The other value.</param>
        /// <remarks>
        /// Equivalency is determined by whether the <see cref="IonValue"/> objects has the same annotations,
        /// hold equal values, or in the case of container, they contain equivalent sets of children.
        /// </remarks>
        private bool IsEquivalentTo(IonValue other)
        {
            if (other == null || Type() != other.Type())
            {
                return(false);
            }

            var otherAnnotations = other._annotations;

            if (_annotations == null)
            {
                return(otherAnnotations == null || otherAnnotations.Count == 0);
            }

            if (otherAnnotations == null || otherAnnotations.Count != _annotations.Count)
            {
                return(false);
            }

            for (int i = 0, l = _annotations.Count; i < l; i++)
            {
                if (!_annotations[i].IsEquivalentTo(otherAnnotations[i]))
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #2
0
 public int GetHashCode(IonValue obj) => obj.GetHashCode();