byteparser.cs

来自「虚拟WEB 服务器」· CS 代码 · 共 50 行

CS
50
字号
namespace Microsoft.VisualStudio.WebHost
{
    using System;

    internal sealed class ByteParser
    {
        private byte[] _bytes;
        private int _pos;

        internal ByteParser(byte[] bytes)
        {
            this._bytes = bytes;
            this._pos = 0;
        }

        internal ByteString ReadLine()
        {
            ByteString str = null;
            for (int i = this._pos; i < this._bytes.Length; i++)
            {
                if (this._bytes[i] == 10)
                {
                    int length = i - this._pos;
                    if ((length > 0) && (this._bytes[i - 1] == 13))
                    {
                        length--;
                    }
                    str = new ByteString(this._bytes, this._pos, length);
                    this._pos = i + 1;
                    return str;
                }
            }
            if (this._pos < this._bytes.Length)
            {
                str = new ByteString(this._bytes, this._pos, this._bytes.Length - this._pos);
            }
            this._pos = this._bytes.Length;
            return str;
        }

        internal int CurrentOffset
        {
            get
            {
                return this._pos;
            }
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?