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
|
|
@ -16,6 +16,7 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Server.Collections;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
|
|
@ -78,6 +79,15 @@ namespace Server
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public int Read(Span<byte> buffer) => _reader.Read(buffer);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public BitArray ReadBitArray()
|
||||
{
|
||||
var length = ((IGenericReader)this).ReadEncodedInt();
|
||||
|
||||
// BinaryReader doesn't expose a Span slice of the buffer, so we use a custom ctor
|
||||
return new BitArray(_reader, length);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public long Seek(long offset, SeekOrigin origin) => _reader.BaseStream.Seek(offset, origin);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue