コード例 #1
0
            private IntPtr _gcHandle;        // The GC Handle to the managed object (the non aggregated object)

            public static unsafe BlindAggregator *CreateInstance()
            {
                BlindAggregator *pResult = (BlindAggregator *)Marshal.AllocCoTaskMem(sizeof(BlindAggregator));

                if (pResult != null)
                {
                    pResult->Construct();
                }

                return(pResult);
            }
コード例 #2
0
            private static unsafe uint Release(BlindAggregator *pThis)
            {
                var result = unchecked ((uint)Interlocked.Decrement(ref pThis->_refCount));

                if (result == 0u)
                {
                    pThis->FinalRelease();
                    Marshal.FreeCoTaskMem((IntPtr)pThis);
                }

                return(result);
            }
コード例 #3
0
 private static unsafe int QueryInterface(BlindAggregator *pThis, [In] ref Guid riid, out IntPtr pvObject)
 {
     if (riid == s_IUnknownInterfaceGuid || riid == s_IComWrapperGuid)
     {
         AddRef(pThis);
         pvObject = (IntPtr)pThis;
         return(S_OK);
     }
     else if (riid == s_IMarshalInterfaceGuid)
     {
         pvObject = IntPtr.Zero;
         return(E_NOINTERFACE);
     }
     else
     {
         // We don't know what the interface is, so aggregate blindly from here
         return(Marshal.QueryInterface(pThis->_innerUnknown, ref riid, out pvObject));
     }
 }
コード例 #4
0
 private static unsafe int GetGCHandlePtr(BlindAggregator *pThis, out IntPtr pResult)
 {
     pResult = pThis->_gcHandle;
     return(S_OK);
 }
コード例 #5
0
 private static unsafe uint AddRef(BlindAggregator *pThis)
 => unchecked ((uint)Interlocked.Increment(ref pThis->_refCount));
コード例 #6
0
        public static unsafe void SetInnerObject(IntPtr wrapperUnknown, IntPtr innerUnknown, IntPtr managedObjectGCHandlePtr)
        {
            BlindAggregator *pWrapper = (BlindAggregator *)wrapperUnknown;

            pWrapper->SetInnerObject(innerUnknown, managedObjectGCHandlePtr);
        }