int IStructuralEquatable.GetHashCode(IEqualityComparer comparer)
        {
            ITupleInternal tupleInternal = (ITupleInternal)((object)this.m_Rest);

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

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

            case 3:
                return(Tuple.CombineHashCodes(comparer.GetHashCode(this.m_Item5), comparer.GetHashCode(this.m_Item6), comparer.GetHashCode(this.m_Item7), tupleInternal.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), tupleInternal.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), tupleInternal.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), tupleInternal.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), tupleInternal.GetHashCode(comparer)));

            default:
                return(-1);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns a string that represents the value of this <see cref="T:System.ValueTuple`8" /> instance.
        /// </summary>
        /// <returns>The string representation of this <see cref="T:System.ValueTuple`8" /> instance.</returns>
        /// <remarks>
        /// The string returned by this method takes the form <c>(Item1, Item2, Item3, Item4, Item5, Item6, Item7, Rest)</c>.
        /// If any field value is <see langword="null" />, it is represented as <see cref="F:System.String.Empty" />.
        /// </remarks>
        public override string ToString()
        {
            ITupleInternal tupleInternal = this.Rest as ITupleInternal;
            T1             t;
            T2             t2;
            T3             t3;
            T4             t4;
            T5             t5;
            T6             t6;
            T7             t7;

            if (tupleInternal == null)
            {
                string[] array = new string[17];
                array[0] = "(";
                int    num = 1;
                ref T1 ptr = ref this.Item1;
                t = default(T1);
                string text;
                if (t == null)
                {
                    t   = this.Item1;
                    ptr = ref t;
                    if (t == null)
                    {
                        text = null;
                        goto IL_5D;
                    }
                }
                text = ptr.ToString();
IL_5D:
                array[num] = text;
                array[2]   = ", ";
                int    num2 = 3;
                ref T2 ptr2 = ref this.Item2;
Exemplo n.º 3
0
        private int GetHashCodeCore(IEqualityComparer comparer)
        {
            ITupleInternal tupleInternal = this.Rest as ITupleInternal;

            if (tupleInternal == null)
            {
                return(ValueTuple.CombineHashCodes(comparer.GetHashCode(this.Item1), comparer.GetHashCode(this.Item2), comparer.GetHashCode(this.Item3), comparer.GetHashCode(this.Item4), comparer.GetHashCode(this.Item5), comparer.GetHashCode(this.Item6), comparer.GetHashCode(this.Item7)));
            }
            int size = tupleInternal.Size;

            if (size >= 8)
            {
                return(tupleInternal.GetHashCode(comparer));
            }
            switch (8 - size)
            {
            case 1:
                return(ValueTuple.CombineHashCodes(comparer.GetHashCode(this.Item7), tupleInternal.GetHashCode(comparer)));

            case 2:
                return(ValueTuple.CombineHashCodes(comparer.GetHashCode(this.Item6), comparer.GetHashCode(this.Item7), tupleInternal.GetHashCode(comparer)));

            case 3:
                return(ValueTuple.CombineHashCodes(comparer.GetHashCode(this.Item5), comparer.GetHashCode(this.Item6), comparer.GetHashCode(this.Item7), tupleInternal.GetHashCode(comparer)));

            case 4:
                return(ValueTuple.CombineHashCodes(comparer.GetHashCode(this.Item4), comparer.GetHashCode(this.Item5), comparer.GetHashCode(this.Item6), comparer.GetHashCode(this.Item7), tupleInternal.GetHashCode(comparer)));

            case 5:
                return(ValueTuple.CombineHashCodes(comparer.GetHashCode(this.Item3), comparer.GetHashCode(this.Item4), comparer.GetHashCode(this.Item5), comparer.GetHashCode(this.Item6), comparer.GetHashCode(this.Item7), tupleInternal.GetHashCode(comparer)));

            case 6:
                return(ValueTuple.CombineHashCodes(comparer.GetHashCode(this.Item2), comparer.GetHashCode(this.Item3), comparer.GetHashCode(this.Item4), comparer.GetHashCode(this.Item5), comparer.GetHashCode(this.Item6), comparer.GetHashCode(this.Item7), tupleInternal.GetHashCode(comparer)));

            case 7:
            case 8:
                return(ValueTuple.CombineHashCodes(comparer.GetHashCode(this.Item1), comparer.GetHashCode(this.Item2), comparer.GetHashCode(this.Item3), comparer.GetHashCode(this.Item4), comparer.GetHashCode(this.Item5), comparer.GetHashCode(this.Item6), comparer.GetHashCode(this.Item7), tupleInternal.GetHashCode(comparer)));

            default:
                return(-1);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns the hash code for the current <see cref="T:System.ValueTuple`8" /> instance.
        /// </summary>
        /// <returns>A 32-bit signed integer hash code.</returns>
        public override int GetHashCode()
        {
            ITupleInternal tupleInternal = this.Rest as ITupleInternal;

            if (tupleInternal == null)
            {
                return(ValueTuple.CombineHashCodes(ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t1Comparer.GetHashCode(this.Item1), ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t2Comparer.GetHashCode(this.Item2), ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t3Comparer.GetHashCode(this.Item3), ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t4Comparer.GetHashCode(this.Item4), ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t5Comparer.GetHashCode(this.Item5), ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t6Comparer.GetHashCode(this.Item6), ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t7Comparer.GetHashCode(this.Item7)));
            }
            int size = tupleInternal.Size;

            if (size >= 8)
            {
                return(tupleInternal.GetHashCode());
            }
            switch (8 - size)
            {
            case 1:
                return(ValueTuple.CombineHashCodes(ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t7Comparer.GetHashCode(this.Item7), tupleInternal.GetHashCode()));

            case 2:
                return(ValueTuple.CombineHashCodes(ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t6Comparer.GetHashCode(this.Item6), ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t7Comparer.GetHashCode(this.Item7), tupleInternal.GetHashCode()));

            case 3:
                return(ValueTuple.CombineHashCodes(ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t5Comparer.GetHashCode(this.Item5), ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t6Comparer.GetHashCode(this.Item6), ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t7Comparer.GetHashCode(this.Item7), tupleInternal.GetHashCode()));

            case 4:
                return(ValueTuple.CombineHashCodes(ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t4Comparer.GetHashCode(this.Item4), ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t5Comparer.GetHashCode(this.Item5), ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t6Comparer.GetHashCode(this.Item6), ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t7Comparer.GetHashCode(this.Item7), tupleInternal.GetHashCode()));

            case 5:
                return(ValueTuple.CombineHashCodes(ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t3Comparer.GetHashCode(this.Item3), ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t4Comparer.GetHashCode(this.Item4), ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t5Comparer.GetHashCode(this.Item5), ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t6Comparer.GetHashCode(this.Item6), ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t7Comparer.GetHashCode(this.Item7), tupleInternal.GetHashCode()));

            case 6:
                return(ValueTuple.CombineHashCodes(ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t2Comparer.GetHashCode(this.Item2), ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t3Comparer.GetHashCode(this.Item3), ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t4Comparer.GetHashCode(this.Item4), ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t5Comparer.GetHashCode(this.Item5), ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t6Comparer.GetHashCode(this.Item6), ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t7Comparer.GetHashCode(this.Item7), tupleInternal.GetHashCode()));

            case 7:
            case 8:
                return(ValueTuple.CombineHashCodes(ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t1Comparer.GetHashCode(this.Item1), ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t2Comparer.GetHashCode(this.Item2), ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t3Comparer.GetHashCode(this.Item3), ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t4Comparer.GetHashCode(this.Item4), ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t5Comparer.GetHashCode(this.Item5), ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t6Comparer.GetHashCode(this.Item6), ValueTuple <T1, T2, T3, T4, T5, T6, T7, TRest> .s_t7Comparer.GetHashCode(this.Item7), tupleInternal.GetHashCode()));

            default:
                return(-1);
            }
        }
Exemplo n.º 5
0
    Int32 IStructuralEquatable.GetHashCode(IEqualityComparer comparer)
    {
        // We want to have a limited hash in this case.  We'll use the last 8 elements of the tuple
        ITupleInternal t = (ITupleInternal)m_Rest;

        if (t.Length >= 8)
        {
            return(t.GetHashCode(comparer));
        }

        // In this case, the rest memeber has less than 8 elements so we need to combine some our elements with the elements in rest
        int k = 8 - t.Length;

        switch (k)
        {
        case 1:
            return(Tuple.CombineHashCodes(comparer.GetHashCode(m_Item7), t.GetHashCode(comparer)));

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

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

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

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

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

        case 7:
            return(Tuple.CombineHashCodes(comparer.GetHashCode(m_Item1), comparer.GetHashCode(m_Item2), comparer.GetHashCode(m_Item3), comparer.GetHashCode(m_Item4), comparer.GetHashCode(m_Item5), comparer.GetHashCode(m_Item6), comparer.GetHashCode(m_Item7), t.GetHashCode(comparer)));
        }
        Contract.Assert(false, "Missed all cases for computing Tuple hash code");
        return(-1);
    }