HandleRef.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // ==++==
  2. //
  3. // Copyright (c) Microsoft Corporation. All rights reserved.
  4. //
  5. // ==--==
  6. namespace System.Runtime.InteropServices
  7. {
  8. using System;
  9. [System.Runtime.InteropServices.ComVisible(true)]
  10. public struct HandleRef
  11. {
  12. // ! Do not add or rearrange fields as the EE depends on this layout.
  13. //------------------------------------------------------------------
  14. internal Object m_wrapper;
  15. internal IntPtr m_handle;
  16. //-----------------------------------------------------------------
  17. public HandleRef(Object wrapper, IntPtr handle)
  18. {
  19. m_wrapper = wrapper;
  20. m_handle = handle;
  21. }
  22. public Object Wrapper
  23. {
  24. get
  25. {
  26. return m_wrapper;
  27. }
  28. }
  29. public IntPtr Handle
  30. {
  31. get
  32. {
  33. return m_handle;
  34. }
  35. }
  36. public static explicit operator IntPtr(HandleRef value)
  37. {
  38. return value.m_handle;
  39. }
  40. public static IntPtr ToIntPtr(HandleRef value)
  41. {
  42. return value.m_handle;
  43. }
  44. }
  45. }