The Labs \ Source Viewer \ SSCLI \ System.Runtime.InteropServices \ HandleRef

  1. // ==++==
  2. //
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. //
  14. // ==--==
  15. namespace System.Runtime.InteropServices
  16. {
  17.    
  18.     using System;
  19.    
  20.     [System.Runtime.InteropServices.ComVisible(true)]
  21.     public struct HandleRef
  22.     {
  23.        
  24.         // ! Do not add or rearrange fields as the EE depends on this layout.
  25.         //------------------------------------------------------------------
  26.         internal object m_wrapper;
  27.         internal IntPtr m_handle;
  28.         //------------------------------------------------------------------
  29.        
  30.        
  31.         public HandleRef(object wrapper, IntPtr handle)
  32.         {
  33.             m_wrapper = wrapper;
  34.             m_handle = handle;
  35.         }
  36.        
  37.         public object Wrapper {
  38.             get { return m_wrapper; }
  39.         }
  40.        
  41.         public IntPtr Handle {
  42.             get { return m_handle; }
  43.         }
  44.        
  45.        
  46.         public static explicit operator IntPtr(HandleRef value)
  47.         {
  48.             return value.m_handle;
  49.         }
  50.        
  51.         public static IntPtr ToIntPtr(HandleRef value)
  52.         {
  53.             return value.m_handle;
  54.         }
  55.     }
  56. }

Developer Fusion