Ejemplo n.º 1
0
        int IStructuralComparable.CompareTo(object other, IComparer comparer)
        {
            if (other == null)
            {
                return(1);
            }

            TMTupleBase otherTuple = other as TMTupleBase;

            if (otherTuple == null ||
                !(otherTuple.GetType().Equals(this.GetType())))
            {
                throw new ArgumentException("other");
            }

            object[] thisValues  = this.GetTupleFieldValues();
            object[] otherValues = otherTuple.GetTupleFieldValues();
            int      size        = thisValues.Length;

            for (int i = 0; i < (size - 1); i++)
            {
                int cv = comparer.Compare(thisValues[i], otherValues[i]);
                if (cv != 0)
                {
                    return(cv);
                }
            }

            return(comparer.Compare(thisValues[size - 1],
                                    otherValues[size - 1]));
        }
Ejemplo n.º 2
0
        bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer)
        {
            TMTupleBase otherTuple = other as TMTupleBase;

            if (otherTuple == null)
            {
                // no tuple
                return(false);
            }

            if (otherTuple.GetType().Equals(this.GetType()) == false)
            {
                // not the same type
                return(false);
            }

            return(CollectionHelper.SequenceEqual(this.GetTupleFieldValues(),
                                                  otherTuple.GetTupleFieldValues()));
        }