Example #1
0
 /// <summary>
 /// Loads the buffer into the pointed location.
 /// </summary>
 /// <param name="pDestination">A pointer to the destination of the data.</param>
 public unsafe void CopyTo(byte *pDestination)
 {
     if (_isDeflated)
     {
         if (_weakInflatedBufferRef.TryGetTarget(out var buffer))
         {
             fixed(byte *pBuffer = buffer)
             {
                 Stdlib.MemCpy(pDestination, pBuffer, (UIntPtr)_actualSize);
             }
         }
         else
         {
             // Decompress the buffer of the ClipboardItem into the destination.
             BlockCompression.Inflate(_buffer, _actualSize, pDestination);
         }
     }
     else
     {
         fixed(byte *pBuffer = _buffer)
         {
             Stdlib.MemCpy(pDestination, pBuffer, (UIntPtr)_actualSize);
         }
     }
 }
Example #2
0
        /// <summary>
        /// Loads the data as a byte array.
        /// </summary>
        /// <returns>The byte array representation of the data.</returns>
        public byte[] GetDataBuffer()
        {
            if (_buffer == null)
            {
                throw new InvalidOperationException();
            }

            if (_isDeflated)
            {
                if (!_weakInflatedBufferRef.TryGetTarget(out byte[] inflatedBuffer))
                {
                    inflatedBuffer = new byte[_actualSize];
                    BlockCompression.Inflate(_buffer, _actualSize, inflatedBuffer);
                    _weakInflatedBufferRef.SetTarget(inflatedBuffer);
                }
                return(inflatedBuffer);
            }
            else
            {
                return(_buffer);
            }
        }