示例#1
0
 public void GetCallbackPtrReturnsPointerToShadow()
 {
     using (var callback = new CallbackImpl())
     {
         Assert.NotEqual(IntPtr.Zero, CppObject.ToCallbackPtr <ICallback>(callback));
     }
 }
示例#2
0
 public void CanRoundTripCallThroughNativeVtblToManagedObject()
 {
     using (var callback = new CallbackImpl())
     {
         var callbackPtr    = CppObject.ToCallbackPtr <ICallback>(callback);
         var methodPtr      = Marshal.ReadIntPtr(Marshal.ReadIntPtr(callbackPtr));
         var delegateObject = Marshal.GetDelegateForFunctionPointer <CallbackShadow.CallbackVbtl.IncrementDelegate>(methodPtr);
         Assert.Equal(3, delegateObject(callbackPtr, 2));
     }
 }