fix: Adds BitArray support with codegen (#888)
* Adds a custom BitArray class with the following added features: * ctor for creating BitArray against read only span * ctor for creating BitArray against BinaryReader * CopyTo to copy a BitArray to a Span * Adds BitArray to UO Primitive serialization so it can be codegenned.
This commit is contained in:
parent
61e2177011
commit
b125146b27
9 changed files with 1489 additions and 19 deletions
|
|
@ -18,6 +18,7 @@ using System.Diagnostics;
|
|||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using Server.Collections;
|
||||
using Server.Text;
|
||||
|
||||
namespace Server
|
||||
|
|
@ -134,6 +135,16 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
public void Write(BitArray bitArray)
|
||||
{
|
||||
var byteLength = BitArray.GetByteArrayLengthFromBitLength(bitArray.Length);
|
||||
FlushIfNeeded(byteLength + 4);
|
||||
|
||||
((IGenericWriter)this).WriteEncodedInt(byteLength);
|
||||
bitArray.CopyTo(_buffer.AsSpan((int)Index, byteLength));
|
||||
Index += byteLength;
|
||||
}
|
||||
|
||||
public virtual long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
Debug.Assert(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue