int IStructuralEquatable.GetHashCode(IEqualityComparer comparer)
        {
            ITuple rest = (ITuple)this.m_Rest;

            if (rest.Size >= 8)
            {
                return(rest.GetHashCode(comparer));
            }
            switch ((8 - rest.Size))
            {
            case 1:
                return(Tuple.CombineHashCodes(comparer.GetHashCode(this.m_Item7), rest.GetHashCode(comparer)));

            case 2:
                return(Tuple.CombineHashCodes(comparer.GetHashCode(this.m_Item6), comparer.GetHashCode(this.m_Item7), rest.GetHashCode(comparer)));

            case 3:
                return(Tuple.CombineHashCodes(comparer.GetHashCode(this.m_Item5), comparer.GetHashCode(this.m_Item6), comparer.GetHashCode(this.m_Item7), rest.GetHashCode(comparer)));

            case 4:
                return(Tuple.CombineHashCodes(comparer.GetHashCode(this.m_Item4), comparer.GetHashCode(this.m_Item5), comparer.GetHashCode(this.m_Item6), comparer.GetHashCode(this.m_Item7), rest.GetHashCode(comparer)));

            case 5:
                return(Tuple.CombineHashCodes(comparer.GetHashCode(this.m_Item3), comparer.GetHashCode(this.m_Item4), comparer.GetHashCode(this.m_Item5), comparer.GetHashCode(this.m_Item6), comparer.GetHashCode(this.m_Item7), rest.GetHashCode(comparer)));

            case 6:
                return(Tuple.CombineHashCodes(comparer.GetHashCode(this.m_Item2), comparer.GetHashCode(this.m_Item3), comparer.GetHashCode(this.m_Item4), comparer.GetHashCode(this.m_Item5), comparer.GetHashCode(this.m_Item6), comparer.GetHashCode(this.m_Item7), rest.GetHashCode(comparer)));

            case 7:
                return(Tuple.CombineHashCodes(comparer.GetHashCode(this.m_Item1), comparer.GetHashCode(this.m_Item2), comparer.GetHashCode(this.m_Item3), comparer.GetHashCode(this.m_Item4), comparer.GetHashCode(this.m_Item5), comparer.GetHashCode(this.m_Item6), comparer.GetHashCode(this.m_Item7), rest.GetHashCode(comparer)));
            }
            return(-1);
        }
Exemple #2
0
        int IStructuralEquatable.GetHashCode(IEqualityComparer comparer)
        {
            ITuple tuple = (ITuple)(object)this.m_Rest;

            if (tuple.Size >= 8)
            {
                return(tuple.GetHashCode(comparer));
            }
            switch (8 - tuple.Size)
            {
            case 1:
                return(Tuple.CombineHashCodes(comparer.GetHashCode((object)this.m_Item7), tuple.GetHashCode(comparer)));

            case 2:
                return(Tuple.CombineHashCodes(comparer.GetHashCode((object)this.m_Item6), comparer.GetHashCode((object)this.m_Item7), tuple.GetHashCode(comparer)));

            case 3:
                return(Tuple.CombineHashCodes(comparer.GetHashCode((object)this.m_Item5), comparer.GetHashCode((object)this.m_Item6), comparer.GetHashCode((object)this.m_Item7), tuple.GetHashCode(comparer)));

            case 4:
                return(Tuple.CombineHashCodes(comparer.GetHashCode((object)this.m_Item4), comparer.GetHashCode((object)this.m_Item5), comparer.GetHashCode((object)this.m_Item6), comparer.GetHashCode((object)this.m_Item7), tuple.GetHashCode(comparer)));

            case 5:
                return(Tuple.CombineHashCodes(comparer.GetHashCode((object)this.m_Item3), comparer.GetHashCode((object)this.m_Item4), comparer.GetHashCode((object)this.m_Item5), comparer.GetHashCode((object)this.m_Item6), comparer.GetHashCode((object)this.m_Item7), tuple.GetHashCode(comparer)));

            case 6:
                return(Tuple.CombineHashCodes(comparer.GetHashCode((object)this.m_Item2), comparer.GetHashCode((object)this.m_Item3), comparer.GetHashCode((object)this.m_Item4), comparer.GetHashCode((object)this.m_Item5), comparer.GetHashCode((object)this.m_Item6), comparer.GetHashCode((object)this.m_Item7), tuple.GetHashCode(comparer)));

            case 7:
                return(Tuple.CombineHashCodes(comparer.GetHashCode((object)this.m_Item1), comparer.GetHashCode((object)this.m_Item2), comparer.GetHashCode((object)this.m_Item3), comparer.GetHashCode((object)this.m_Item4), comparer.GetHashCode((object)this.m_Item5), comparer.GetHashCode((object)this.m_Item6), comparer.GetHashCode((object)this.m_Item7), tuple.GetHashCode(comparer)));

            default:
                return(-1);
            }
        }
 protected void AssertAreSame(ITuple dummyTuple, ITuple tuple)
 {
     for (int i = 0; i < dummyTuple.Count; i++)
     {
         bool available = dummyTuple.GetFieldState(i).IsAvailable();
         try {
             Assert.AreEqual(available, tuple.GetFieldState(i).IsAvailable());
         }
         catch (AssertionException)
         {
             Console.Out.WriteLine(string.Format("Tuple type: {0}", tuple.GetType().Name));
             Console.Out.WriteLine(string.Format("Field Index: {0}", i));
             Console.Out.WriteLine();
         }
     }
     Assert.AreEqual(dummyTuple.GetHashCode(), tuple.GetHashCode());
     Assert.IsTrue(dummyTuple.Equals(tuple));
     Assert.IsTrue(tuple.Equals(dummyTuple));
 }