Esempio n. 1
0
        public virtual int Compare(T x, T y)
        {
            if (ReferenceEquals(x, y))
            {
                return(0);
            }
            if (x == null)
            {
                return(1);
            }
            if (y == null)
            {
                return(-1);
            }

            int n = FirstComparer.Compare(x, y);

            return(n != 0 ? n : SecondComparer.Compare(x, y));
        }
        public bool Equals(TaggedUnion <TFirst, TSecond> other)
        {
            if (tag != other.tag)
            {
                return(false);
            }

            if (tag == Tag.First)
            {
                return(FirstComparer.Equals(first, other.first));
            }

            if (tag == Tag.Second)
            {
                return(SecondComparer.Equals(second, other.second));
            }

            return(true);
        }