Merge pull request #3028 from lateralusX/jlorenss/threadpool_warning
[mono.git] / mcs / class / referencesource / mscorlib / system / runtime / interopservices / dispatchwrapper.cs
1 // ==++==
2 // 
3 //   Copyright (c) Microsoft Corporation.  All rights reserved.
4 // 
5 // ==--==
6 /*=============================================================================
7 **
8 ** Class: DispatchWrapper.
9 **
10 **
11 ** Purpose: Wrapper that is converted to a variant with VT_DISPATCH.
12 **
13 **
14 =============================================================================*/
15 #if !FULL_AOT_RUNTIME
16 namespace System.Runtime.InteropServices {
17    
18     using System;
19     using System.Security;
20     using System.Security.Permissions;
21
22     [Serializable]
23 [System.Runtime.InteropServices.ComVisible(true)]
24     public sealed class DispatchWrapper
25     {
26         [System.Security.SecuritySafeCritical]  // auto-generated
27 #pragma warning disable 618
28         [SecurityPermissionAttribute(SecurityAction.Demand,Flags=SecurityPermissionFlag.UnmanagedCode)]
29 #pragma warning restore 618
30         public DispatchWrapper(Object obj)
31         {
32             if (obj != null)
33             {
34                 // Make sure this guy has an IDispatch
35                 IntPtr pdisp = Marshal.GetIDispatchForObject(obj);
36
37                 // If we got here without throwing an exception, the QI for IDispatch succeeded.
38                 Marshal.Release(pdisp);
39             }
40             m_WrappedObject = obj;
41         }
42
43         public Object WrappedObject 
44         {
45             get 
46             {
47                 return m_WrappedObject;
48             }
49         }
50
51         private Object m_WrappedObject;
52     }
53 }
54 #endif