Serialization update

pull/1/head
unknown 6 years ago
parent 3134b5a16e
commit 8e59fa2755

@ -14,6 +14,12 @@ namespace ZeroLevel.Services.Serialization
: IBinaryReader : IBinaryReader
{ {
private readonly Stream _stream; private readonly Stream _stream;
private bool _reverseByteOrder = false;
public void ReverseByteOrder(bool use_reverse_byte_order)
{
_reverseByteOrder = use_reverse_byte_order;
}
public MemoryStreamReader(byte[] data) public MemoryStreamReader(byte[] data)
{ {
@ -136,6 +142,16 @@ namespace ZeroLevel.Services.Serialization
var readedCount = _stream.Read(buffer, 0, count); var readedCount = _stream.Read(buffer, 0, count);
if (count != readedCount) if (count != readedCount)
throw new InvalidOperationException($"The stream returned less data ({count} bytes) than expected ({readedCount} bytes)"); throw new InvalidOperationException($"The stream returned less data ({count} bytes) than expected ({readedCount} bytes)");
if (_reverseByteOrder)
{
byte b;
for (int i = 0; i < (count >> 1); i++)
{
b = buffer[i];
buffer[i] = buffer[count - i];
buffer[count - i] = b;
}
}
return buffer; return buffer;
} }

@ -5,15 +5,15 @@
<Description>Infrastructure layer library</Description> <Description>Infrastructure layer library</Description>
<Authors>ogoun</Authors> <Authors>ogoun</Authors>
<Company>ogoun</Company> <Company>ogoun</Company>
<AssemblyVersion>2.0.2.0</AssemblyVersion> <AssemblyVersion>2.0.3.0</AssemblyVersion>
<PackageReleaseNotes>Fix IExClient contract</PackageReleaseNotes> <PackageReleaseNotes>Update serialization</PackageReleaseNotes>
<PackageProjectUrl>https://github.com/ogoun/Zero/wiki</PackageProjectUrl> <PackageProjectUrl>https://github.com/ogoun/Zero/wiki</PackageProjectUrl>
<Copyright>Copyright Ogoun 2019</Copyright> <Copyright>Copyright Ogoun 2019</Copyright>
<PackageLicenseUrl>https://opensource.org/licenses/MIT</PackageLicenseUrl> <PackageLicenseUrl>https://opensource.org/licenses/MIT</PackageLicenseUrl>
<PackageIconUrl>https://raw.githubusercontent.com/ogoun/Zero/master/zero.png</PackageIconUrl> <PackageIconUrl>https://raw.githubusercontent.com/ogoun/Zero/master/zero.png</PackageIconUrl>
<RepositoryUrl>https://github.com/ogoun/Zero</RepositoryUrl> <RepositoryUrl>https://github.com/ogoun/Zero</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType> <RepositoryType>GitHub</RepositoryType>
<Version>2.0.2</Version> <Version>2.0.3</Version>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

Loading…
Cancel
Save

Powered by TurnKey Linux.