Update Reference Sources to .NET Framework 4.6.1
[mono.git] / mcs / class / referencesource / mscorlib / system / runtime / interopservices / windowsruntime / eventregistrationtoken.cs
1 // ==++==
2 // 
3 //   Copyright (c) Microsoft Corporation.  All rights reserved.
4 // 
5 // ==--==
6 //
7 // <OWNER>[....]</OWNER>
8 // <OWNER>[....]</OWNER>
9 // <OWNER>[....]</OWNER>
10
11 using System;
12
13 namespace System.Runtime.InteropServices.WindowsRuntime
14 {
15     // Event registration tokens are 64 bit opaque structures returned from WinRT style event adders, in order
16     // to signify a registration of a particular delegate to an event.  The token's only real use is to
17     // unregister the same delgate from the event at a later time.
18     public struct EventRegistrationToken
19     {
20         internal ulong m_value;
21
22         internal EventRegistrationToken(ulong value)
23         {
24             m_value = value;
25         }
26
27         internal ulong Value
28         {
29             get { return m_value; }
30         }
31
32         public static bool operator ==(EventRegistrationToken left, EventRegistrationToken right)
33         {
34             return left.Equals(right);
35         }
36
37         public static bool operator !=(EventRegistrationToken left, EventRegistrationToken right)
38         {
39             return !left.Equals(right);
40         }
41
42         public override bool Equals(object obj)
43         {
44             if (!(obj is EventRegistrationToken))
45             {
46                 return false;
47             }
48
49             return ((EventRegistrationToken)obj).Value == Value;
50         }
51
52         public override int GetHashCode()
53         {
54             return m_value.GetHashCode();
55         }
56     }
57 }