public static byte[] ToArray(this IBuffer source, uint sourceIndex, int count)
        {
            if (source is null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            return(UwpBuffer.Cast(source).ToArray(sourceIndex, count));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Writes the contents of the specified buffer to the output stream.
        /// </summary>
        /// <param name="buffer">The buffer.</param>
        public void WriteBuffer(IBuffer buffer)
        {
            if (buffer is null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }

            var data = Buffer.Cast(buffer).GetSegment();

            _memoryStream.Write(data.Array !, data.Offset, data.Count);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Writes the specified bytes from a buffer to the output stream.
        /// </summary>
        /// <param name="buffer">The buffer.</param>
        /// <param name="start">The starting byte.</param>
        /// <param name="count">The number of bytes to write.</param>
        public void WriteBuffer(IBuffer buffer, uint start, uint count)
        {
            if (buffer is null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }

            if (start >= buffer.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(start));
            }

            var data = Buffer.Cast(buffer).GetSegment();

            if (count > data.Count)
            {
                throw new ArgumentOutOfRangeException(nameof(count));
            }

            _memoryStream.Write(data.Array !, data.Offset + (int)start, (int)count);
        }
Exemplo n.º 4
0
        private static async Task WriteBufferTaskAsync(IStorageFile file, IBuffer buffer)
        {
            var data = UwpBuffer.Cast(buffer).GetSegment();

            await WriteBytesTaskAsync(file, data.Array !, data.Offset, data.Count);
        }
Exemplo n.º 5
0
Arquivo: FileIO.cs Projeto: x86/uno
        private static async Task WriteBufferTaskAsync(IStorageFile file, IBuffer buffer, CancellationToken cancellationToken)
        {
            var data = UwpBuffer.Cast(buffer).GetSegment();

            await WriteBytesTaskAsync(file, data.Array !, cancellationToken);
        }
 public static byte[] ToArray(this IBuffer source)
 => UwpBuffer.Cast(source).ToArray();
 public static byte GetByte(this IBuffer source, uint byteOffset)
 => UwpBuffer.Cast(source).GetByte(byteOffset);
 public static bool IsSameData(this IBuffer buffer, IBuffer otherBuffer)
 => UwpBuffer.Cast(buffer).Span.SequenceEqual(UwpBuffer.Cast(otherBuffer).Span);
 public static void CopyTo(this IBuffer source, IBuffer destination)
 => UwpBuffer.Cast(source).CopyTo(0, UwpBuffer.Cast(destination), 0, destination.Capacity);
 public static void CopyTo(this IBuffer source, uint sourceIndex, IBuffer destination, uint destinationIndex, uint count)
 => UwpBuffer.Cast(source).CopyTo(sourceIndex, UwpBuffer.Cast(destination), destinationIndex, count);
 public static void CopyTo(this IBuffer source, uint sourceIndex, byte[] destination, int destinationIndex, int count)
 => UwpBuffer.Cast(source).CopyTo(sourceIndex, destination, destinationIndex, count);
 public static void CopyTo(this IBuffer source, byte[] destination)
 => UwpBuffer.Cast(source).CopyTo(0, destination, 0, destination.Length);
 public static void CopyTo(this byte[] source, int sourceIndex, IBuffer destination, uint destinationIndex, int count)
 => UwpBuffer.Cast(destination).Write(destinationIndex, source, sourceIndex, count);
 public static void CopyTo(this byte[] source, IBuffer destination)
 => UwpBuffer.Cast(destination).Write(0, source, 0, source.Length);
 public static Stream AsStream(this IBuffer source)
 => new StreamOverBuffer(UwpBuffer.Cast(source));