Exemple #1
0
        /// <summary>
        /// Create a copy of existing managed data.
        /// </summary>
        /// <param name="data">Data to be copied.</param>
        /// <returns>Wrapped copy to unmanaged buffer.</returns>
        public static UnmanagedBuffer CreateCopyFrom(byte[] data)
        {
            var result = UnmanagedBuffer.Allocate(data.Length);

            result.CopyFrom(data);
            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Copy from unmanaged buffer.
        /// </summary>
        /// <param name="source">Unmanaged buffer from which to copy.</param>
        public void CopyFrom(UnmanagedBuffer source)
        {
            if (source == null)
            {
                throw new ArgumentException("Source unmanaged array is null.");
            }
            else if (this.size != source.Size)
            {
                throw new ArgumentException("Source unmanaged array is not of the same size.");
            }

            CopyUnmanagedMemory(this.data, source.data, this.size);
        }
Exemple #3
0
 /// <summary>
 /// Copy this unmanaged buffer to another instance.
 /// </summary>
 /// <param name="destination">Destination instance to which to copy.</param>
 public void CopyTo(UnmanagedBuffer destination)
 {
     if (destination == null)
     {
         throw new ArgumentException("Destination unmanaged array is null.");
     }
     else if (destination.size != this.size)
     {
         throw new ArgumentException("Destination unmanaged array is not of the same size.");
     }
     else
     {
         CopyUnmanagedMemory(destination.data, this.data, this.size);
     }
 }