[amd64/tramp] hide interpreter specific trampoline behind ifdef
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / Base / Shared / Internal / EqualityArray.cs
1 namespace System.Activities.Presentation.Internal {
2
3     using System.Diagnostics;
4     using System.Runtime;
5
6     //
7     // An EqualityArray is an array of objects whose
8     // .Equals method runs against all items in the 
9     // array.  It is assumed that the data input
10     // into the array is constant.  We use this in attributes
11     // to offer a quick and accurate TypeId property.
12     //
13     internal class EqualityArray {
14         private object[] _values;
15
16         internal EqualityArray(params object[] values) {
17             _values = values;
18             Fx.Assert(_values != null && _values.Length > 0, "EqualityArray expects at least one value");
19         }
20
21         public override bool Equals(object other) {
22             EqualityArray otherArray = other as EqualityArray;
23             if (otherArray == null) return false;
24             if (otherArray._values.Length != _values.Length) return false;
25             for (int idx = 0; idx < _values.Length; idx++) {
26                 if (_values[idx] != otherArray._values[idx]) return false;
27             }
28             return true;
29         }
30
31         public override int GetHashCode() {
32             return _values[0].GetHashCode();
33         }
34     }
35 }
36