Esempio n. 1
0
        static ComPtr()
        {
            ComPtr <IUnknown> p;

            Debug.Assert(ComPtr.GetAddressOf(&p) == &p._ptr);

            // *probably* not a valid COM type without a GUID
            Debug.Assert(typeof(T).GetCustomAttribute(typeof(GuidAttribute)) != null);
            CachedGuidHandle    = GCHandle.Alloc(CachedGuid, GCHandleType.Pinned);
            PointerToCachedGuid = (Guid *)CachedGuidHandle.AddrOfPinnedObject();
        }
Esempio n. 2
0
        private static Guid *Initialize()
        {
            UniqueComPtr <IUnknown> p = default;

            Debug.Assert(ComPtr.GetAddressOf(&p) == &p._ptr);

            // *probably* not a valid COM type without a GUID
#if REFLECTION
            Debug.Assert(typeof(T).GetCustomAttribute <GuidAttribute>() is not null);
#endif

            var ptr = (Guid *)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(T), sizeof(Guid));
            *ptr = typeof(T).GUID;
            return(ptr);
        }