WriteAsync_AbstractStream() static private method

static private WriteAsync_AbstractStream ( Stream stream, Windows.Storage.Streams.IBuffer buffer ) : UInt32>.IAsyncOperationWithProgress
stream Stream
buffer Windows.Storage.Streams.IBuffer
return UInt32>.IAsyncOperationWithProgress
        public IAsyncOperationWithProgress<uint, uint> WriteAsync(IBuffer buffer)
        {
            if (buffer == null)
            {
                // Mapped to E_POINTER.
                throw new ArgumentNullException(nameof(buffer));
            }

            if (buffer.Capacity < buffer.Length)
            {
                ArgumentException ex = new ArgumentException(global::Windows.Storage.Streams.SR.Argument_BufferLengthExceedsCapacity);
                ex.SetHResult(E_INVALIDARG);
                throw ex;
            }

            Stream str = EnsureNotDisposed();
            return StreamOperationsImplementation.WriteAsync_AbstractStream(str, buffer);
        }
Exemplo n.º 2
0
        public IAsyncOperationWithProgress <UInt32, UInt32> WriteAsync(IBuffer buffer)
        {
            if (buffer == null)
            {
                // Mapped to E_POINTER.
                throw new ArgumentNullException("buffer");
            }

            if (buffer.Capacity < buffer.Length)
            {
                ArgumentException ex = new ArgumentException(SR.Argument_BufferLengthExceedsCapacity);
                ex.SetErrorCode(HResults.E_INVALIDARG);
                throw ex;
            }

            // Commented due to a reported CCRewrite bug. Should uncomment when fixed:
            //Contract.Ensures(Contract.Result<IAsyncOperationWithProgress<UInt32, UInt32>>() != null);
            //Contract.EndContractBlock();

            Stream str = EnsureNotDisposed();

            return(StreamOperationsImplementation.WriteAsync_AbstractStream(str, buffer));
        }