• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# StreamMode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中StreamMode的典型用法代码示例。如果您正苦于以下问题:C# StreamMode类的具体用法?C# StreamMode怎么用?C# StreamMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StreamMode类属于命名空间,在下文中一共展示了StreamMode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Request

        /// <summary>
        ///     This method is called when stream is requested, if you return a stream
        ///     it will return it to the user else it will keep trying all the other StreamFactorys
        ///     until one does return a stream.
        /// </summary>
        /// <param name="path">Path of file or object to create stream to.</param>
        /// <param name="mode">Determines how to open or create stream.</param>
        /// <returns>A Stream instance or NULL if this factory can't open the given stream.</returns>
        protected override Stream Request(object path, StreamMode mode)
        {
            // if (File.Exists(path.ToString()) == false && moede != StreamMode.Open) return null;
            try
            {
                switch (mode)
                {
                    case StreamMode.Append:
                        if (Directory.Exists(Path.GetDirectoryName(path.ToString()))) Directory.CreateDirectory(Path.GetDirectoryName(path.ToString()));
                        if (File.Exists(path.ToString()) == false) File.Create(path.ToString()).Close();
                        return new FileStream(path.ToString(), FileMode.Append);

                    case StreamMode.Open:
                        return new FileStream(path.ToString(), FileMode.Open);

                    case StreamMode.Truncate:
                        if (Directory.Exists(Path.GetDirectoryName(path.ToString()))) Directory.CreateDirectory(Path.GetDirectoryName(path.ToString()));
                        if (File.Exists(path.ToString()) == false) File.Create(path.ToString()).Close();
                        return new FileStream(path.ToString(), FileMode.Truncate);

                }
            }
            catch (Exception) {}
            return null;
        }
开发者ID:HampsterEater,项目名称:FusionGameEngine,代码行数:33,代码来源:Default+Factory.cs


示例2: QueueStream

 public QueueStream(Stream stream, StreamMode mode, int bufferSize, BufferManager bufferManager)
 {
     if (mode == StreamMode.Read)
     {
         _stream = new ReadStream(stream, bufferSize, bufferManager);
     }
     else if (mode == StreamMode.Write)
     {
         _stream = new WriteStream(new CacheStream(stream, QueueStream.BlockSize, bufferManager), bufferSize, bufferManager);
     }
 }
开发者ID:networkelements,项目名称:Library,代码行数:11,代码来源:QueueStream.cs


示例3: FlacStream

        public FlacStream(string file, StreamMode mode, StreamAccessMode accessMode)
        {
            FileMode fileMode;
            FileAccess fileAccessMode;

            switch (mode)
            {
                case StreamMode.CreateNew:
                {
                    fileMode = FileMode.Create;
                    break;
                }
                case StreamMode.OpenExisting:
                {
                    fileMode = FileMode.Open;
                    break;
                }
                default:
                {
                    throw new FlacDebugException();
                }
            }

            switch (accessMode)
            {
                case StreamAccessMode.Read:
                case StreamAccessMode.Write:
                case StreamAccessMode.Both:
                {
                    fileAccessMode = (FileAccess)accessMode;
                    break;
                }
                default:
                {
                    throw new FlacDebugException();
                }
            }
            fileStream_ = new FileStream(file, fileMode, fileAccessMode, FileShare.Read);

            if ((accessMode & StreamAccessMode.Read) == StreamAccessMode.Read)
            {
                reader_ = new FlacStreamReader(fileStream_);
            }
            if ((accessMode & StreamAccessMode.Write) == StreamAccessMode.Write)
            {
                writer_ = new FlacStreamWriter(fileStream_);
            }
        }
开发者ID:LastContrarian,项目名称:flacfs,代码行数:48,代码来源:FlacStream.cs


示例4: Request

        /// <summary>
        ///     This method is called when stream is requested, if you return a stream
        ///     it will return it to the user else it will keep trying all the other StreamFactorys
        ///     until one does return a stream.
        /// </summary>
        /// <param name="path">Path of file or object to create stream to.</param>
        /// <param name="mode">Determines how to open or create stream.</param>
        /// <returns>A Stream instance or NULL if this factory can't open the given stream.</returns>
        protected override Stream Request(object path,StreamMode mode)
        {
            if (path.ToString().ToLower().Substring(0, 4) != "[email protected]") return null;

            // Check if we have been handed a capacity as well.
            if (path.ToString().Length > 4)
            {
                string capacityStr = path.ToString().Substring(4, path.ToString().Length - 4);
                int capacity = 0;
                if (int.TryParse(capacityStr, out capacity) == true)
                    return new MemoryStream(capacity);
                else
                    return new MemoryStream();
            }
            else
            {
                return new MemoryStream();
            }
        }
开发者ID:HampsterEater,项目名称:FusionGameEngine,代码行数:27,代码来源:Memory+Factory.cs


示例5: BizTalkMessagePartStream

        /// <summary>
        /// Initializes a new instance of the <see cref="BizTalkMessagePartStream"/> class.
        /// </summary>
        /// <param name="stream">The stream from which to read (or write if in compression mode).</param>
        /// <param name="mode">The compression mode.</param>
        public BizTalkMessagePartStream(Stream stream, StreamMode mode)
        {
            this.innerStream = stream;
            this.streamMode = mode;

            if (mode == StreamMode.Write)
            {
                this.writeStream = new BizTalkBlockStream(this.innerStream);
            }
            else if (mode == StreamMode.Read)
            {
                this.reader = new BizTalkBlockReader(stream);
                this.readBuffer = new MemoryStream();
            }
            else
            {
                throw new ArgumentException("Unknown stream mode specified: " + mode, "mode");
            }
        }
开发者ID:niik,项目名称:DtaSpy,代码行数:24,代码来源:BizTalkMessagePartStream.cs


示例6: lock

        Task<int> IStreamReader.ReadAsync(byte[] buffer, int offset, int length, StreamMode mode)
        {
            Utilities.DebugCheckStreamArguments(buffer, offset, length, mode);

            lock (this)
            {
                int total = 0;

                while (length > 0)
                {
                    while (mBuffer == null)
                    {
                        if (mComplete)
                            return Task.FromResult(total);

                        Monitor.Wait(this);
                    }

                    int copied = Math.Min(length, mLength);
                    System.Diagnostics.Debug.Assert(copied > 0);
                    Buffer.BlockCopy(mBuffer, mOffset, buffer, offset, copied);
                    mOffset += copied;
                    mLength -= copied;
                    offset += copied;
                    length -= copied;
                    total += copied;

                    if (mLength == 0)
                    {
                        mBuffer = null;
                        Monitor.PulseAll(this);
                    }

                    if (mode == StreamMode.Partial)
                        break;
                }

                return Task.FromResult(total);
            }
        }
开发者ID:modulexcite,项目名称:managed-lzma,代码行数:40,代码来源:CopyEncoder.cs


示例7: Write

        public override void Write(System.Byte[] buffer, int offset, int count)
        {
            // workitem 7159
            // calculate the CRC on the unccompressed data  (before writing)
            if (crc != null)
                crc.SlurpBlock(buffer, offset, count);

            if (_streamMode == StreamMode.Undefined)
                _streamMode = StreamMode.Writer;
            else if (_streamMode != StreamMode.Writer)
                throw new ZlibException("Cannot Write after Reading.");

            if (count == 0)
                return;

            // first reference of z property will initialize the private var _z
            z.InputBuffer = buffer;
            _z.NextIn = offset;
            _z.AvailableBytesIn = count;
            bool done = false;
            do
            {
                _z.OutputBuffer = workingBuffer;
                _z.NextOut = 0;
                _z.AvailableBytesOut = _workingBuffer.Length;
                int rc = (_wantCompress)
                    ? _z.Deflate(_flushMode)
                    : _z.Inflate(_flushMode);
                if (rc != ZlibConstants.Z_OK && rc != ZlibConstants.Z_STREAM_END)
                    throw new ZlibException((_wantCompress ? "de" : "in") + "flating: " + _z.Message);

                //if (_workingBuffer.Length - _z.AvailableBytesOut > 0)
                _stream.Write(_workingBuffer, 0, _workingBuffer.Length - _z.AvailableBytesOut);

                done = _z.AvailableBytesIn == 0 && _z.AvailableBytesOut != 0;

                // If GZIP and de-compress, we're done when 8 bytes remain.
                if (_flavor == ZlibStreamFlavor.GZIP && !_wantCompress)
                    done = (_z.AvailableBytesIn == 8 && _z.AvailableBytesOut != 0);

            }
            while (!done);
        }
开发者ID:Cardanis,项目名称:MonoGame,代码行数:43,代码来源:ZlibStream.cs


示例8: Write

        /// <param name="buffer"></param><param name="offset"></param> <param name="count"></param><exception cref = "ZlibException"></exception><exception cref = "ZlibException"></exception>
        public override void Write(byte[] buffer, int offset, int count)
        {
            // workitem 7159
            // calculate the CRC on the unccompressed data  (before writing)
            if (this.crc != null)
            {
                this.crc.SlurpBlock(buffer, offset, count);
            }

            if (this.Mode == StreamMode.Undefined)
            {
                this.Mode = StreamMode.Writer;
            }
            else if (this.Mode != StreamMode.Writer)
            {
                throw new ZlibException("Cannot Write after Reading.");
            }

            if (count == 0)
            {
                return;
            }

            // first reference of z property will initialize the private var _z
            this.Z.InputBuffer = buffer;
            this.ZlibCodec.NextIn = offset;
            this.ZlibCodec.AvailableBytesIn = count;
            bool done;
            do
            {
                this.ZlibCodec.OutputBuffer = this.WorkingBuffer;
                this.ZlibCodec.NextOut = 0;
                this.ZlibCodec.AvailableBytesOut = this.workBuffer.Length;
                int rc = this.WantCompress ? this.ZlibCodec.Deflate(this.flushMode) : this.ZlibCodec.Inflate();
                if (rc != ZlibConstants.Zok && rc != ZlibConstants.ZStreamEnd)
                {
                    throw new ZlibException((this.WantCompress ? "de" : "in") + "flating: " + this.ZlibCodec.Message);
                }

                // if (_workingBuffer.Length - _z.AvailableBytesOut > 0)
                this.Stream.Write(this.workBuffer, 0, this.workBuffer.Length - this.ZlibCodec.AvailableBytesOut);

                done = this.ZlibCodec.AvailableBytesIn == 0 && this.ZlibCodec.AvailableBytesOut != 0;

                // If GZIP and de-compress, we're done when 8 bytes remain.
                if (this.flavor == ZlibStreamFlavor.Gzip && !this.WantCompress)
                {
                    done = this.ZlibCodec.AvailableBytesIn == 8 && this.ZlibCodec.AvailableBytesOut != 0;
                }
            }
            while (!done);
        }
开发者ID:robertbaker,项目名称:SevenUpdate,代码行数:53,代码来源:ZlibBaseStream.cs


示例9: RealizeFont

 /// <summary>
 /// Makes the specified font and brush to the current graphics objects.
 /// </summary>
 void RealizeFont(Glyphs glyphs)
 {
   if (this.streamMode != StreamMode.Text)
   {
     this.streamMode = StreamMode.Text;
     WriteLiteral("BT\n");
     // Text matrix is empty after BT
     this.graphicsState.realizedTextPosition = new XPoint();
   }
   this.graphicsState.RealizeFont(glyphs);
 }
开发者ID:AnthonyNystrom,项目名称:Pikling,代码行数:14,代码来源:PdfContentWriter.cs


示例10: Realize

    /// <summary>
    /// Makes the specified font and brush to the current graphics objects.
    /// </summary>
    void Realize(XFont font, XBrush brush, int renderMode)
    {
      BeginPage();
      RealizeTransform();

      if (this.streamMode != StreamMode.Text)
      {
        this.streamMode = StreamMode.Text;
        this.content.Append("BT\n");
        // Text matrix is empty after BT
        this.gfxState.realizedTextPosition = new XPoint();
      }
      this.gfxState.RealizeFont(font, brush, renderMode);
    }
开发者ID:zheimer,项目名称:PDFSharp,代码行数:17,代码来源:XGraphicsPdfRenderer.cs


示例11: Write

        public override void Write(System.Byte[] buffer, int offset, int length)
        {
            if (_streamMode == StreamMode.Undefined) _streamMode = StreamMode.Writer;
            if (_streamMode != StreamMode.Writer)
                throw new ZlibException("Cannot Write after Reading.");

            if (length == 0)
                return;

            _z.InputBuffer = buffer;
            _z.NextIn = offset;
            _z.AvailableBytesIn = length;
            do
            {
                _z.OutputBuffer = _workingBuffer;
                _z.NextOut = 0;
                _z.AvailableBytesOut = _workingBuffer.Length;
                int rc = (_wantCompress)
                    ? 1
                    : _z.Inflate(_flushMode);
                if (rc != ZlibConstants.Z_OK && rc != ZlibConstants.Z_STREAM_END)
                    throw new ZlibException((_wantCompress ? "de" : "in") + "flating: " + _z.Message);
                _stream.Write(_workingBuffer, 0, _workingBuffer.Length - _z.AvailableBytesOut);
            }
            while (_z.AvailableBytesIn > 0 || _z.AvailableBytesOut == 0);
        }
开发者ID:Esri,项目名称:arcgis-toolkit-sl-wpf,代码行数:26,代码来源:ZlibStream.cs


示例12: Read

        public override int Read( byte [] buffer, int offset, int count )
        {
            if ( streamMode == StreamMode.Undefined )
            {
                if ( !this.stream.CanRead ) throw new CompressionProcessException ( "The stream is not readable." );
                streamMode = StreamMode.Reader;
                z.AvailableBytesIn = 0;
            }

            if ( streamMode != StreamMode.Reader )
                throw new CompressionProcessException ( "Cannot Read after Writing." );

            if ( count == 0 ) return 0;
            if ( nomoreinput && _wantCompress ) return 0;
            if ( buffer == null ) throw new ArgumentNullException ( "buffer" );
            if ( count < 0 ) throw new ArgumentOutOfRangeException ( "count" );
            if ( offset < buffer.GetLowerBound ( 0 ) ) throw new ArgumentOutOfRangeException ( "offset" );
            if ( ( offset + count ) > buffer.GetLength ( 0 ) ) throw new ArgumentOutOfRangeException ( "count" );

            int rc = 0;

            _z.OutputBuffer = buffer;
            _z.NextOut = offset;
            _z.AvailableBytesOut = count;

            _z.InputBuffer = workingBuffer;

            do
            {
                if ( ( _z.AvailableBytesIn == 0 ) && ( !nomoreinput ) )
                {
                    _z.NextIn = 0;
                    _z.AvailableBytesIn = stream.Read ( _workingBuffer, 0, _workingBuffer.Length );
                    if ( _z.AvailableBytesIn == 0 )
                        nomoreinput = true;
                }
                rc = ( _wantCompress )
                    ? _z.Deflate ( flushMode )
                    : _z.Inflate ( flushMode );

                if ( nomoreinput && ( rc == ZlibConstants.Z_BUF_ERROR ) )
                    return 0;

                if ( rc != ZlibConstants.Z_OK && rc != ZlibConstants.Z_STREAM_END )
                    throw new CompressionProcessException ( String.Format ( "{0}flating:  rc={1}  msg={2}", ( _wantCompress ? "de" : "in" ), rc, _z.Message ) );

                if ( ( nomoreinput || rc == ZlibConstants.Z_STREAM_END ) && ( _z.AvailableBytesOut == count ) )
                    break;
            }
            while ( _z.AvailableBytesOut > 0 && !nomoreinput && rc == ZlibConstants.Z_OK );

            if ( _z.AvailableBytesOut > 0 )
            {
                if ( rc == ZlibConstants.Z_OK && _z.AvailableBytesIn == 0 )
                {

                }

                if ( nomoreinput )
                {
                    if ( _wantCompress )
                    {
                        rc = _z.Deflate ( FlushType.Finish );
                        if ( rc != ZlibConstants.Z_OK && rc != ZlibConstants.Z_STREAM_END )
                            throw new CompressionProcessException ( String.Format ( "Deflating:  rc={0}  msg={1}", rc, _z.Message ) );
                    }
                }
            }

            rc = ( count - _z.AvailableBytesOut );

            return rc;
        }
开发者ID:Daramkun,项目名称:ProjectLiqueur,代码行数:73,代码来源:ZlibBaseStream.cs


示例13: WriteAsync

        public Task<int> WriteAsync(byte[] buffer, int offset, int length, StreamMode mode)
        {
            Utilities.CheckStreamArguments(buffer, offset, length, mode);

            int processed = 0;

            while (length > 0)
            {
                Frame frame;
                lock (mSyncObject)
                {
                    System.Diagnostics.Debug.Assert(mRunning);

                    if (mDisposeTask != null)
                        throw new OperationCanceledException();

                    while (mQueue.Count == 0)
                    {
                        Monitor.Wait(mSyncObject);

                        if (mDisposeTask != null)
                            throw new OperationCanceledException();
                    }

                    frame = mQueue.Peek();
                }

                var capacity = frame.mEnding - frame.mOffset;
                var copySize = Math.Min(capacity, length > Int32.MaxValue ? Int32.MaxValue : (int)length);
                Buffer.BlockCopy(buffer, offset, frame.mBuffer, frame.mOffset, copySize);
                frame.mOffset += copySize;
                offset += copySize;
                processed += copySize;
                length -= copySize;

                if (copySize == capacity || frame.mMode == StreamMode.Partial)
                {
                    frame.mCompletion.SetResult(frame.mOffset - frame.mOrigin);

                    lock (mSyncObject)
                    {
                        System.Diagnostics.Debug.Assert(mRunning);
                        var other = mQueue.Dequeue();
                        System.Diagnostics.Debug.Assert(other == frame);
                    }
                }
            }

            return Task.FromResult(processed);
        }
开发者ID:modulexcite,项目名称:managed-lzma,代码行数:50,代码来源:StreamHelper.cs


示例14: ReadAsync

        public Task<int> ReadAsync(byte[] buffer, int offset, int length, StreamMode mode)
        {
            Utilities.CheckStreamArguments(buffer, offset, length, mode);

            var frame = new Frame();
            frame.mBuffer = buffer;
            frame.mOrigin = offset;
            frame.mOffset = offset;
            frame.mEnding = offset + length;
            frame.mMode = mode;

            lock (mSyncObject)
            {
                if (mDisposeTask != null)
                    throw new ObjectDisposedException(null);

                mQueue.Enqueue(frame);
                Monitor.Pulse(mSyncObject);
            }

            return frame.mCompletion.Task;
        }
开发者ID:modulexcite,项目名称:managed-lzma,代码行数:22,代码来源:StreamHelper.cs


示例15: Write

        public override void Write( System.Byte [] buffer, int offset, int count )
        {
            if ( streamMode == StreamMode.Undefined )
                streamMode = StreamMode.Writer;
            else if ( streamMode != StreamMode.Writer )
                throw new CompressionProcessException ( "Cannot Write after Reading." );

            if ( count == 0 )
                return;

            z.InputBuffer = buffer;
            _z.NextIn = offset;
            _z.AvailableBytesIn = count;
            bool done = false;
            do
            {
                _z.OutputBuffer = workingBuffer;
                _z.NextOut = 0;
                _z.AvailableBytesOut = _workingBuffer.Length;
                int rc = ( _wantCompress )
                    ? _z.Deflate ( flushMode )
                    : _z.Inflate ( flushMode );
                if ( rc != ZlibConstants.Z_OK && rc != ZlibConstants.Z_STREAM_END )
                    throw new CompressionProcessException ( ( _wantCompress ? "de" : "in" ) + "flating: " + _z.Message );

                stream.Write ( _workingBuffer, 0, _workingBuffer.Length - _z.AvailableBytesOut );

                done = _z.AvailableBytesIn == 0 && _z.AvailableBytesOut != 0;
            }
            while ( !done );
        }
开发者ID:Daramkun,项目名称:ProjectLiqueur,代码行数:31,代码来源:ZlibBaseStream.cs


示例16: Read

        public override System.Int32 Read(System.Byte[] buffer, System.Int32 offset, System.Int32 count)
        {
            if (_streamMode == StreamMode.Undefined)
            {
                // for the first read, set up some controls.
                _streamMode = StreamMode.Reader;
                _z.AvailableBytesIn = 0;
            }
            if (_streamMode != StreamMode.Reader)
                throw new ZlibException("Cannot Read after Writing.");

            if (!this._stream.CanRead) throw new ZlibException("The stream is not readable.");
            if (count == 0)
                return 0;

            int rc;

            // set up the output of the deflate/inflate codec:
            _z.OutputBuffer = buffer;
            _z.NextOut = offset;
            _z.AvailableBytesOut = count;

            // this is not always necessary, but is helpful in case _workingBuffer has been resized. (new byte[])
            _z.InputBuffer = _workingBuffer;

            do
            {
                // need data in _workingBuffer in order to deflate/inflate.  Here, we check if we have any.
                if ((_z.AvailableBytesIn == 0) && (!nomoreinput))
                {
                    // No data available, so try to Read data from the captive stream.
                    _z.NextIn = 0;
                    _z.AvailableBytesIn = SharedUtils.ReadInput(_stream, _workingBuffer, 0, _workingBuffer.Length);
                    //(bufsize<z.avail_out ? bufsize : z.avail_out));
                    if (_z.AvailableBytesIn == -1)
                    {
                        _z.AvailableBytesIn = 0;
                        nomoreinput = true;
                    }
                }
                // we have data in InputBuffer; now compress or decompress as appropriate
                rc = (_wantCompress)
                    ? -1
                    : _z.Inflate(_flushMode);

                if (nomoreinput && (rc == ZlibConstants.Z_BUF_ERROR))
                    return (-1);
                if (rc != ZlibConstants.Z_OK && rc != ZlibConstants.Z_STREAM_END)
                    throw new ZlibException((_wantCompress ? "de" : "in") + "flating: " + _z.Message);
                if ((nomoreinput || rc == ZlibConstants.Z_STREAM_END) && (_z.AvailableBytesOut == count))
                    return (-1);
            }
            while (_z.AvailableBytesOut == count && rc == ZlibConstants.Z_OK);

            return (count - _z.AvailableBytesOut);
        }
开发者ID:Esri,项目名称:arcgis-toolkit-sl-wpf,代码行数:56,代码来源:ZlibStream.cs


示例17: Write

        // workitem 7813 - totally unnecessary
        //         public override void WriteByte(byte b)
        //         {
        //             _buf1[0] = (byte)b;
        //             // workitem 7159
        //             if (crc != null)
        //                 crc.SlurpBlock(_buf1, 0, 1);
        //             Write(_buf1, 0, 1);
        //         }

        public override void Write(byte[] buffer, int offset, int count)
        {
            // workitem 7159
            // calculate the CRC on the unccompressed data  (before writing)
            if (this.crc != null)
                this.crc.SlurpBlock(buffer, offset, count);

            if (this.streamMode == StreamMode.Undefined)
                this.streamMode = StreamMode.Writer;
            else if (this.streamMode != StreamMode.Writer)
                throw new ZlibException("Cannot Write after Reading.");

            if (count == 0)
                return;

            // first reference of z property will initialize the private var _z
            this.z.InputBuffer = buffer;
            this.z.NextIn = offset;
            this.z.AvailableBytesIn = count;

            bool done;

            do
            {
                this.z.OutputBuffer = this.WorkingBuffer;
                this.z.NextOut = 0;
                this.z.AvailableBytesOut = this.workingBuffer.Length;

                //int rc = (_wantCompress)
                //    ? _z.Deflate(_flushMode)
                //    : _z.Inflate(_flushMode);
                int rc = this.z.Inflate(this.FlushMode);

                if (rc != ZlibConstants.Z_OK && rc != ZlibConstants.Z_STREAM_END)
                    throw new ZlibException("inflating: " + this.z.Message);

                this.Stream.Write(this.workingBuffer, 0, this.workingBuffer.Length - this.z.AvailableBytesOut);

                done = this.z.AvailableBytesIn == 0 && this.z.AvailableBytesOut != 0;

                // If GZIP and de-compress, we're done when 8 bytes remain.
                if (this.Flavor == ZlibStreamFlavor.Gzip)
                    done = (this.z.AvailableBytesIn == 8 && this.z.AvailableBytesOut != 0);
            }
            while (!done);
        }
开发者ID:CL0SeY,项目名称:RestSharp,代码行数:56,代码来源:ZLibStream.cs


示例18: SetQHYCCDStreamMode

 public static extern int SetQHYCCDStreamMode(IntPtr handle, StreamMode mode);
开发者ID:hpavlov,项目名称:occurec,代码行数:1,代码来源:QHYPInvoke.cs


示例19: WriteAsync

        public async Task<int> WriteAsync(byte[] buffer, int offset, int length, StreamMode mode)
        {
            System.Diagnostics.Debug.Assert(mEncoderOutput == null);
            System.Diagnostics.Debug.Assert(!mCompletionTask.Task.IsCompleted);

            // TODO: calculate checksum asynchronously?
            if (mCalculateChecksum)
                for (int i = 0; i < length; i++)
                    mChecksum = CRC.Update(mChecksum, buffer[offset + i]);

            await mStream.WriteAsync(buffer, offset, length).ConfigureAwait(false);
            return length;
        }
开发者ID:modulexcite,项目名称:managed-lzma,代码行数:13,代码来源:Runtime.cs


示例20: ReadOutputAsync

        /// <summary>
        /// Read output data from the decoder. You should not use the specified region of the buffer until the returned task completes.
        /// </summary>
        /// <param name="buffer">The buffer into which output data should be written.</param>
        /// <param name="offset">The offset at which output data should be written.</param>
        /// <param name="length">The maximum number of bytes which should be written.</param>
        /// <param name="mode">
        /// Specifies whether to wait until the whole output buffer has been filled,
        /// or wether to return as soon as some data is available.
        /// </param>
        /// <returns>A task which, when completed, tells you how much data has been read.</returns>
        public Task<int> ReadOutputAsync(byte[] buffer, int offset, int length, StreamMode mode)
        {
            if (buffer == null)
                throw new ArgumentNullException(nameof(buffer));

            if (offset < 0 || offset > buffer.Length)
                throw new ArgumentOutOfRangeException(nameof(offset));

            if (length < 0 || length > buffer.Length - offset)
                throw new ArgumentOutOfRangeException(nameof(length));

            if (mode != StreamMode.Complete && mode != StreamMode.Partial)
                throw new ArgumentOutOfRangeException(nameof(mode));

            var frame = new OutputFrame();
            frame.mBuffer = buffer;
            frame.mOrigin = offset;
            frame.mOffset = offset;
            frame.mEnding = offset + length;
            frame.mMode = mode;
            PushOutputFrame(frame);
            return frame.mCompletion.Task;
        }
开发者ID:modulexcite,项目名称:managed-lzma,代码行数:34,代码来源:Decoder.cs



注:本文中的StreamMode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# StreamReader类代码示例发布时间:2022-05-24
下一篇:
C# StreamKind类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap