示例#1
0
 public static string GetStringFromBlob(IDxcLibrary library, IDxcBlob blob)
 {
     unsafe
     {
         blob = library.GetBlobAstUf16(blob);
         return(new string(blob.GetBufferPointer(), 0, (int)(blob.GetBufferSize() / 2)));
     }
 }
        public T CreateReflection <T>(IDxcBlob blob) where T : ComObject
        {
            DxcBuffer reflectionData = new DxcBuffer
            {
                Ptr      = blob.GetBufferPointer(),
                Size     = blob.GetBufferSize(),
                Encoding = Dxc.DXC_CP_ACP
            };

            CreateReflection(ref reflectionData, typeof(T).GUID, out IntPtr nativePtr).CheckError();
            return(MarshallingHelpers.FromPointer <T>(nativePtr));
        }
示例#3
0
        public static byte[] GetBytesFromBlob(IDxcBlob blob)
        {
            unsafe
            {
                byte * pMem   = (byte *)blob.GetBufferPointer();
                uint   size   = blob.GetBufferSize();
                byte[] result = new byte[size];
                fixed(byte *pTarget = result)
                {
                    for (uint i = 0; i < size; ++i)
                    {
                        pTarget[i] = pMem[i];
                    }
                }

                return(result);
            }
        }
        public Result CreateReflection <T>(IDxcBlob blob, out T?reflection) where T : ComObject
        {
            DxcBuffer reflectionData = new DxcBuffer
            {
                Ptr      = blob.GetBufferPointer(),
                Size     = blob.GetBufferSize(),
                Encoding = Dxc.DXC_CP_ACP
            };

            Result result = CreateReflection(ref reflectionData, typeof(T).GUID, out IntPtr nativePtr);

            if (result.Failure)
            {
                reflection = default;
                return(result);
            }

            reflection = MarshallingHelpers.FromPointer <T>(nativePtr);
            return(result);
        }