Пример #1
0
            public void WriteBytes(byte[] data, int offset, int length)
            {
                if (data == null)
                {
                    throw new ArgumentNullException("传入的数组不可为空");
                }
                switch (mWireType)
                {
                case WireType.Fixed32:
                    if (length != 4)
                    {
                        throw new InvalidOperationException("length");
                    }
                    goto CopyFixedLength;

                case WireType.Fixed64:
                    if (length != 8)
                    {
                        throw new InvalidOperationException("长度与类型不对应 length:" + length + "wiretype:" + mWireType);
                    }
                    goto CopyFixedLength;

                case WireType.String:
                    WriteUInt32Variant((uint)length);
                    goto CopyFixedLength;
                }
                throw new InvalidOperationException("WriteBytes WireType 类型错误");
CopyFixedLength:
                ChoseLength(length);
                PBHelperCSLE.BlockCopy(data, offset, mDate, mIndex, length);
                IncrementedAndReset(length);
            }