System.Drawing: added email to icon and test file headers
[mono.git] / mcs / class / System / System.Diagnostics / CounterSample.cs
index 846fd76c610be4ee82c715fe238eeaa99a1715a0..b357c17c8c2969844a644d3e7b250b8ef2babdc3 100644 (file)
@@ -34,6 +34,8 @@ namespace System.Diagnostics {
 
        public struct CounterSample {
                
+               // do not reorder and keep in sync with the runtime
+               // in metadata/mono-perfcounters.c
                private long rawValue;
                private long baseValue;
                private long counterFrequency;
@@ -122,6 +124,50 @@ namespace System.Diagnostics {
                {
                        return CounterSampleCalculator.ComputeCounterValue (counterSample, nextCounterSample);
                }
+
+#if NET_2_0
+               public override bool Equals (object obj)
+               {
+                       if (!(obj is CounterSample))
+                               return false;
+                       return Equals ((CounterSample) obj);
+               }
+
+               public bool Equals (CounterSample other)
+               {
+                       return
+                               rawValue == other.rawValue &&
+                               baseValue == other.counterFrequency &&
+                               counterFrequency == other.counterFrequency &&
+                               systemFrequency == other.systemFrequency &&
+                               timeStamp == other.timeStamp &&
+                               timeStamp100nSec == other.timeStamp100nSec &&
+                               counterTimeStamp == other.counterTimeStamp &&
+                               counterType == other.counterType;
+               }
+
+               public static bool operator == (CounterSample obj1, CounterSample obj2)
+               {
+                       return obj1.Equals (obj2);
+               }
+
+               public static bool operator != (CounterSample obj1, CounterSample obj2)
+               {
+                       return !obj1.Equals (obj2);
+               }
+
+               public override int GetHashCode ()
+               {
+                       return (int) (rawValue << 28 ^
+                               (baseValue << 24 ^
+                               (counterFrequency << 20 ^
+                               (systemFrequency << 16 ^
+                               (timeStamp << 8 ^
+                               (timeStamp100nSec << 4 ^
+                               (counterTimeStamp ^
+                               (int) counterType)))))));
+               }
+#endif
        }
 }