0
|
1 using System;
|
|
2
|
|
3 namespace BLToolkit.Common
|
|
4 {
|
|
5 [Obsolete("Use System.Tuple")]
|
|
6 public struct Tuple<T1,T2>
|
|
7 {
|
|
8 public Tuple(T1 field1, T2 field2)
|
|
9 {
|
|
10 Field1 = field1;
|
|
11 Field2 = field2;
|
|
12 }
|
|
13
|
|
14 public readonly T1 Field1;
|
|
15 public readonly T2 Field2;
|
|
16
|
|
17 public override int GetHashCode()
|
|
18 {
|
|
19 int hash1 = Field1 == null ? 0 : Field1.GetHashCode();
|
|
20 int hash2 = Field2 == null ? 0 : Field2.GetHashCode();
|
|
21
|
|
22 return ((hash1 << 5) + hash1) ^ hash2;
|
|
23 }
|
|
24
|
|
25 public override bool Equals(object obj)
|
|
26 {
|
|
27 if (obj is Tuple<T1,T2>)
|
|
28 {
|
|
29 Tuple<T1,T2> t = (Tuple<T1,T2>)obj;
|
|
30
|
|
31 return
|
|
32 (Field1 == null ? t.Field1 == null : Field1.Equals(t.Field1)) &&
|
|
33 (Field2 == null ? t.Field2 == null : Field2.Equals(t.Field2));
|
|
34 }
|
|
35
|
|
36 return false;
|
|
37 }
|
|
38 }
|
|
39
|
|
40 [Obsolete("Use System.Tuple")]
|
|
41 public struct Tuple<T1,T2,T3>
|
|
42 {
|
|
43 public Tuple(T1 field1, T2 field2, T3 field3)
|
|
44 {
|
|
45 Field1 = field1;
|
|
46 Field2 = field2;
|
|
47 Field3 = field3;
|
|
48 }
|
|
49
|
|
50 public readonly T1 Field1;
|
|
51 public readonly T2 Field2;
|
|
52 public readonly T3 Field3;
|
|
53
|
|
54 public override int GetHashCode()
|
|
55 {
|
|
56 int hash1 = Field1 == null ? 0 : Field1.GetHashCode();
|
|
57 int hash2 = Field2 == null ? 0 : Field2.GetHashCode();
|
|
58
|
|
59 hash1 = ((hash1 << 5) + hash1) ^ hash2;
|
|
60 hash2 = Field3 == null ? 0 : Field3.GetHashCode();
|
|
61
|
|
62 return ((hash1 << 5) + hash1) ^ hash2;
|
|
63 }
|
|
64
|
|
65 public override bool Equals(object obj)
|
|
66 {
|
|
67 if (obj is Tuple<T1,T2,T3>)
|
|
68 {
|
|
69 Tuple<T1,T2,T3> t = (Tuple<T1,T2,T3>)obj;
|
|
70
|
|
71 return
|
|
72 (Field1 == null ? t.Field1 == null : Field1.Equals(t.Field1)) &&
|
|
73 (Field2 == null ? t.Field2 == null : Field2.Equals(t.Field2)) &&
|
|
74 (Field3 == null ? t.Field3 == null : Field3.Equals(t.Field3));
|
|
75 }
|
|
76
|
|
77 return false;
|
|
78 }
|
|
79 }
|
|
80
|
|
81 [Obsolete("Use System.Tuple")]
|
|
82 public struct Tuple<T1,T2,T3,T4>
|
|
83 {
|
|
84 public Tuple(T1 field1, T2 field2, T3 field3, T4 field4)
|
|
85 {
|
|
86 Field1 = field1;
|
|
87 Field2 = field2;
|
|
88 Field3 = field3;
|
|
89 Field4 = field4;
|
|
90 }
|
|
91
|
|
92 public readonly T1 Field1;
|
|
93 public readonly T2 Field2;
|
|
94 public readonly T3 Field3;
|
|
95 public readonly T4 Field4;
|
|
96
|
|
97 public override int GetHashCode()
|
|
98 {
|
|
99 int hash1 = Field1 == null ? 0 : Field1.GetHashCode();
|
|
100 int hash2 = Field2 == null ? 0 : Field2.GetHashCode();
|
|
101
|
|
102 hash1 = ((hash1 << 5) + hash1) ^ hash2;
|
|
103 hash2 = Field3 == null ? 0 : Field3.GetHashCode();
|
|
104
|
|
105 hash1 = ((hash1 << 5) + hash1) ^ hash2;
|
|
106 hash2 = Field4 == null ? 0 : Field4.GetHashCode();
|
|
107
|
|
108 return ((hash1 << 5) + hash1) ^ hash2;
|
|
109 }
|
|
110
|
|
111 public override bool Equals(object obj)
|
|
112 {
|
|
113 if (obj is Tuple<T1,T2,T3,T4>)
|
|
114 {
|
|
115 Tuple<T1,T2,T3,T4> t = (Tuple<T1,T2,T3,T4>)obj;
|
|
116
|
|
117 return
|
|
118 (Field1 == null ? t.Field1 == null : Field1.Equals(t.Field1)) &&
|
|
119 (Field2 == null ? t.Field2 == null : Field2.Equals(t.Field2)) &&
|
|
120 (Field3 == null ? t.Field3 == null : Field3.Equals(t.Field3)) &&
|
|
121 (Field4 == null ? t.Field4 == null : Field4.Equals(t.Field4));
|
|
122 }
|
|
123
|
|
124 return false;
|
|
125 }
|
|
126 }
|
|
127 }
|