[bcl] More netstandard api matching
[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
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 #if FULL_AOT_RUNTIME
35                 throw new PlatformNotSupportedException ();
36 #else
37                 // Make sure this guy has an IDispatch
38                 IntPtr pdisp = Marshal.GetIDispatchForObject(obj);
39
40                 // If we got here without throwing an exception, the QI for IDispatch succeeded.
41                 Marshal.Release(pdisp);
42 #endif
43             }
44             m_WrappedObject = obj;
45         }
46
47         public Object WrappedObject 
48         {
49             get 
50             {
51                 return m_WrappedObject;
52             }
53         }
54
55         private Object m_WrappedObject;
56     }
57 }