123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- using System;
- public sealed class Tuple<T1, T2, T3>
- {
- public Tuple(T1 item1, T2 item2, T3 item3)
- {
- this.item1 = item1;
- this.item2 = item2;
- this.item3 = item3;
- }
- public T1 Item1
- {
- get
- {
- return this.item1;
- }
- }
- public T2 Item2
- {
- get
- {
- return this.item2;
- }
- }
- public T3 Item3
- {
- get
- {
- return this.item3;
- }
- }
- public override int GetHashCode()
- {
- int num = 17;
- int num2 = num * 23;
- int num3;
- if (this.item1 == null)
- {
- num3 = 0;
- }
- else
- {
- T1 t = this.item1;
- num3 = t.GetHashCode();
- }
- num = num2 + num3;
- int num4 = num * 23;
- int num5;
- if (this.item2 == null)
- {
- num5 = 0;
- }
- else
- {
- T2 t2 = this.item2;
- num5 = t2.GetHashCode();
- }
- num = num4 + num5;
- int num6 = num * 23;
- int num7;
- if (this.item3 == null)
- {
- num7 = 0;
- }
- else
- {
- T3 t3 = this.item3;
- num7 = t3.GetHashCode();
- }
- return num6 + num7;
- }
- public override bool Equals(object o)
- {
- if (!(o is Tuple<T1, T2, T3>))
- {
- return false;
- }
- Tuple<T1, T2, T3> b = (Tuple<T1, T2, T3>)o;
- return this == b;
- }
- public static bool operator ==(Tuple<T1, T2, T3> a, Tuple<T1, T2, T3> b)
- {
- if (object.ReferenceEquals(a, null))
- {
- return object.ReferenceEquals(b, null);
- }
- if (a.item1 == null && b.item1 != null)
- {
- return false;
- }
- if (a.item2 == null && b.item2 != null)
- {
- return false;
- }
- if (a.item3 == null && b.item3 != null)
- {
- return false;
- }
- T1 t = a.item1;
- if (t.Equals(b.item1))
- {
- T2 t2 = a.item2;
- if (t2.Equals(b.item2))
- {
- T3 t3 = a.item3;
- return t3.Equals(b.item3);
- }
- }
- return false;
- }
- public static bool operator !=(Tuple<T1, T2, T3> a, Tuple<T1, T2, T3> b)
- {
- return !(a == b);
- }
- public void Unpack(Action<T1, T2, T3> unpackerDelegate)
- {
- unpackerDelegate(this.Item1, this.Item2, this.Item3);
- }
- private readonly T1 item1;
- private readonly T2 item2;
- private readonly T3 item3;
- }
|