Пример #1
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));
        }
Пример #2
0
        public void GetCallbackPtrReturnsPointerToShadow()
        {
            using var callback = new CallbackImpl();

            Assert.NotEqual(IntPtr.Zero, CppObject.ToCallbackPtr <ICallback>(callback));
        }
Пример #3
0
        public void GetCallbackPtrReturnsPointerToShadow()
        {
            using var callback = new CallbackImpl();

            Assert.NotEqual(IntPtr.Zero, MarshallingHelpers.ToCallbackPtr <ICallback>(callback));
        }