Ejemplo n.º 1
0
        public override unsafe int TryAs <U>(Guid iid, out ObjectReference <U> objRef)
        {
            objRef = null;
            int hr = VftblIUnknown.QueryInterface(ThisPtr, ref iid, out IntPtr thatPtr);

            if (hr >= 0)
            {
                if (IsAggregated)
                {
                    Marshal.Release(thatPtr);
                }
                AddRefFromTrackerSource();

                using (var contextCallbackReference = ObjectReference <ABI.WinRT.Interop.IContextCallback.Vftbl> .FromAbi(_contextCallbackPtr))
                {
                    objRef = new ObjectReferenceWithContext <U>(thatPtr, contextCallbackReference.GetRef())
                    {
                        IsAggregated            = IsAggregated,
                        PreventReleaseOnDispose = IsAggregated,
                        ReferenceTrackerPtr     = ReferenceTrackerPtr
                    };
                }
            }
            return(hr);
        }
Ejemplo n.º 2
0
        public override unsafe int TryAs <U>(Guid iid, out ObjectReference <U> objRef)
        {
            objRef = null;
            int hr = VftblIUnknown.QueryInterface(ThisPtr, ref iid, out IntPtr thatPtr);

            if (hr >= 0)
            {
                using (var contextCallbackReference = ObjectReference <ABI.WinRT.Interop.IContextCallback.Vftbl> .FromAbi(_contextCallbackPtr))
                {
                    objRef = new ObjectReferenceWithContext <U>(thatPtr, contextCallbackReference.GetRef());
                }
            }
            return(hr);
        }
Ejemplo n.º 3
0
        public override unsafe int TryAs <U>(Guid iid, out ObjectReference <U> objRef)
        {
            objRef = null;

            int hr = VftblIUnknown.QueryInterface(ThisPtr, ref iid, out IntPtr thatPtr);

            if (hr >= 0)
            {
                if (IsAggregated)
                {
                    Marshal.Release(thatPtr);
                }
                AddRefFromTrackerSource();

                objRef = new ObjectReferenceWithContext <U>(thatPtr, Context.GetContextCallback(), Context.GetContextToken(), _agileReference, iid)
                {
                    IsAggregated            = IsAggregated,
                    PreventReleaseOnDispose = IsAggregated,
                    ReferenceTrackerPtr     = ReferenceTrackerPtr
                };
            }

            return(hr);
        }