Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port netuv core #21

Merged
merged 2 commits into from
Sep 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions DotNetty.Netstandard.sln
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetty.End2End.Tests", "t
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetty.Suite.Tests", "test\DotNetty.Suite.Tests.Netstandard\DotNetty.Suite.Tests.csproj", "{D7063A5D-CEEE-4496-96E9-AA244B44744B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetty.NetUV.Netstandard", "src\DotNetty.NetUV\DotNetty.NetUV.Netstandard.csproj", "{70213847-9E6A-4880-8808-CE469A75D42D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetty.NetUV.Tests", "test\DotNetty.NetUV.Tests.Netstandard\DotNetty.NetUV.Tests.csproj", "{21FCDAD0-26FC-41E6-B385-DEAB88BD661B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -476,6 +480,38 @@ Global
{D7063A5D-CEEE-4496-96E9-AA244B44744B}.Release|x64.Build.0 = Release|Any CPU
{D7063A5D-CEEE-4496-96E9-AA244B44744B}.Release|x86.ActiveCfg = Release|Any CPU
{D7063A5D-CEEE-4496-96E9-AA244B44744B}.Release|x86.Build.0 = Release|Any CPU
{70213847-9E6A-4880-8808-CE469A75D42D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{70213847-9E6A-4880-8808-CE469A75D42D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{70213847-9E6A-4880-8808-CE469A75D42D}.Debug|ARM.ActiveCfg = Debug|Any CPU
{70213847-9E6A-4880-8808-CE469A75D42D}.Debug|ARM.Build.0 = Debug|Any CPU
{70213847-9E6A-4880-8808-CE469A75D42D}.Debug|x64.ActiveCfg = Debug|Any CPU
{70213847-9E6A-4880-8808-CE469A75D42D}.Debug|x64.Build.0 = Debug|Any CPU
{70213847-9E6A-4880-8808-CE469A75D42D}.Debug|x86.ActiveCfg = Debug|Any CPU
{70213847-9E6A-4880-8808-CE469A75D42D}.Debug|x86.Build.0 = Debug|Any CPU
{70213847-9E6A-4880-8808-CE469A75D42D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{70213847-9E6A-4880-8808-CE469A75D42D}.Release|Any CPU.Build.0 = Release|Any CPU
{70213847-9E6A-4880-8808-CE469A75D42D}.Release|ARM.ActiveCfg = Release|Any CPU
{70213847-9E6A-4880-8808-CE469A75D42D}.Release|ARM.Build.0 = Release|Any CPU
{70213847-9E6A-4880-8808-CE469A75D42D}.Release|x64.ActiveCfg = Release|Any CPU
{70213847-9E6A-4880-8808-CE469A75D42D}.Release|x64.Build.0 = Release|Any CPU
{70213847-9E6A-4880-8808-CE469A75D42D}.Release|x86.ActiveCfg = Release|Any CPU
{70213847-9E6A-4880-8808-CE469A75D42D}.Release|x86.Build.0 = Release|Any CPU
{21FCDAD0-26FC-41E6-B385-DEAB88BD661B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{21FCDAD0-26FC-41E6-B385-DEAB88BD661B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{21FCDAD0-26FC-41E6-B385-DEAB88BD661B}.Debug|ARM.ActiveCfg = Debug|Any CPU
{21FCDAD0-26FC-41E6-B385-DEAB88BD661B}.Debug|ARM.Build.0 = Debug|Any CPU
{21FCDAD0-26FC-41E6-B385-DEAB88BD661B}.Debug|x64.ActiveCfg = Debug|Any CPU
{21FCDAD0-26FC-41E6-B385-DEAB88BD661B}.Debug|x64.Build.0 = Debug|Any CPU
{21FCDAD0-26FC-41E6-B385-DEAB88BD661B}.Debug|x86.ActiveCfg = Debug|Any CPU
{21FCDAD0-26FC-41E6-B385-DEAB88BD661B}.Debug|x86.Build.0 = Debug|Any CPU
{21FCDAD0-26FC-41E6-B385-DEAB88BD661B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{21FCDAD0-26FC-41E6-B385-DEAB88BD661B}.Release|Any CPU.Build.0 = Release|Any CPU
{21FCDAD0-26FC-41E6-B385-DEAB88BD661B}.Release|ARM.ActiveCfg = Release|Any CPU
{21FCDAD0-26FC-41E6-B385-DEAB88BD661B}.Release|ARM.Build.0 = Release|Any CPU
{21FCDAD0-26FC-41E6-B385-DEAB88BD661B}.Release|x64.ActiveCfg = Release|Any CPU
{21FCDAD0-26FC-41E6-B385-DEAB88BD661B}.Release|x64.Build.0 = Release|Any CPU
{21FCDAD0-26FC-41E6-B385-DEAB88BD661B}.Release|x86.ActiveCfg = Release|Any CPU
{21FCDAD0-26FC-41E6-B385-DEAB88BD661B}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -506,6 +542,8 @@ Global
{EE14EB67-04A4-45AE-91F0-0A0DB36D7C0B} = {2CCCD679-102A-4422-97D8-DA1A55DAFCA5}
{37F48AC6-2A51-45AF-AEF0-1C83CB076B4E} = {2CCCD679-102A-4422-97D8-DA1A55DAFCA5}
{D7063A5D-CEEE-4496-96E9-AA244B44744B} = {2CCCD679-102A-4422-97D8-DA1A55DAFCA5}
{70213847-9E6A-4880-8808-CE469A75D42D} = {3D04C4DC-6F8E-4326-9569-92F3E26C6EEB}
{21FCDAD0-26FC-41E6-B385-DEAB88BD661B} = {2CCCD679-102A-4422-97D8-DA1A55DAFCA5}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A659CEFB-DDB3-49BE-AEDD-FF2F1B3297DB}
Expand Down
38 changes: 38 additions & 0 deletions DotNetty.sln
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetty.End2End.Tests", "t
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetty.Suite.Tests", "test\DotNetty.Suite.Tests\DotNetty.Suite.Tests.csproj", "{920F73C7-7FBE-44BE-8A99-3A394207D4C8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetty.NetUV", "src\DotNetty.NetUV\DotNetty.NetUV.csproj", "{68548ECD-222C-40C8-B975-46A17E5D5038}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetty.NetUV.Tests", "test\DotNetty.NetUV.Tests\DotNetty.NetUV.Tests.csproj", "{1C3FD988-6CBF-4EAE-A78D-F7D8BA085E0D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -507,6 +511,38 @@ Global
{920F73C7-7FBE-44BE-8A99-3A394207D4C8}.Release|x64.Build.0 = Release|Any CPU
{920F73C7-7FBE-44BE-8A99-3A394207D4C8}.Release|x86.ActiveCfg = Release|Any CPU
{920F73C7-7FBE-44BE-8A99-3A394207D4C8}.Release|x86.Build.0 = Release|Any CPU
{68548ECD-222C-40C8-B975-46A17E5D5038}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{68548ECD-222C-40C8-B975-46A17E5D5038}.Debug|Any CPU.Build.0 = Debug|Any CPU
{68548ECD-222C-40C8-B975-46A17E5D5038}.Debug|ARM.ActiveCfg = Debug|Any CPU
{68548ECD-222C-40C8-B975-46A17E5D5038}.Debug|ARM.Build.0 = Debug|Any CPU
{68548ECD-222C-40C8-B975-46A17E5D5038}.Debug|x64.ActiveCfg = Debug|Any CPU
{68548ECD-222C-40C8-B975-46A17E5D5038}.Debug|x64.Build.0 = Debug|Any CPU
{68548ECD-222C-40C8-B975-46A17E5D5038}.Debug|x86.ActiveCfg = Debug|Any CPU
{68548ECD-222C-40C8-B975-46A17E5D5038}.Debug|x86.Build.0 = Debug|Any CPU
{68548ECD-222C-40C8-B975-46A17E5D5038}.Release|Any CPU.ActiveCfg = Release|Any CPU
{68548ECD-222C-40C8-B975-46A17E5D5038}.Release|Any CPU.Build.0 = Release|Any CPU
{68548ECD-222C-40C8-B975-46A17E5D5038}.Release|ARM.ActiveCfg = Release|Any CPU
{68548ECD-222C-40C8-B975-46A17E5D5038}.Release|ARM.Build.0 = Release|Any CPU
{68548ECD-222C-40C8-B975-46A17E5D5038}.Release|x64.ActiveCfg = Release|Any CPU
{68548ECD-222C-40C8-B975-46A17E5D5038}.Release|x64.Build.0 = Release|Any CPU
{68548ECD-222C-40C8-B975-46A17E5D5038}.Release|x86.ActiveCfg = Release|Any CPU
{68548ECD-222C-40C8-B975-46A17E5D5038}.Release|x86.Build.0 = Release|Any CPU
{1C3FD988-6CBF-4EAE-A78D-F7D8BA085E0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1C3FD988-6CBF-4EAE-A78D-F7D8BA085E0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1C3FD988-6CBF-4EAE-A78D-F7D8BA085E0D}.Debug|ARM.ActiveCfg = Debug|Any CPU
{1C3FD988-6CBF-4EAE-A78D-F7D8BA085E0D}.Debug|ARM.Build.0 = Debug|Any CPU
{1C3FD988-6CBF-4EAE-A78D-F7D8BA085E0D}.Debug|x64.ActiveCfg = Debug|Any CPU
{1C3FD988-6CBF-4EAE-A78D-F7D8BA085E0D}.Debug|x64.Build.0 = Debug|Any CPU
{1C3FD988-6CBF-4EAE-A78D-F7D8BA085E0D}.Debug|x86.ActiveCfg = Debug|Any CPU
{1C3FD988-6CBF-4EAE-A78D-F7D8BA085E0D}.Debug|x86.Build.0 = Debug|Any CPU
{1C3FD988-6CBF-4EAE-A78D-F7D8BA085E0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1C3FD988-6CBF-4EAE-A78D-F7D8BA085E0D}.Release|Any CPU.Build.0 = Release|Any CPU
{1C3FD988-6CBF-4EAE-A78D-F7D8BA085E0D}.Release|ARM.ActiveCfg = Release|Any CPU
{1C3FD988-6CBF-4EAE-A78D-F7D8BA085E0D}.Release|ARM.Build.0 = Release|Any CPU
{1C3FD988-6CBF-4EAE-A78D-F7D8BA085E0D}.Release|x64.ActiveCfg = Release|Any CPU
{1C3FD988-6CBF-4EAE-A78D-F7D8BA085E0D}.Release|x64.Build.0 = Release|Any CPU
{1C3FD988-6CBF-4EAE-A78D-F7D8BA085E0D}.Release|x86.ActiveCfg = Release|Any CPU
{1C3FD988-6CBF-4EAE-A78D-F7D8BA085E0D}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -539,6 +575,8 @@ Global
{A8473C9F-08FF-47DE-8C23-D2BAF5EF4E0A} = {013DFD29-E1DB-4968-A67B-C2342E6F5B6E}
{E6B102FE-C706-4C40-B4F9-569EFC89B70F} = {01F3CC7E-F996-411E-AFD6-72673A826549}
{920F73C7-7FBE-44BE-8A99-3A394207D4C8} = {01F3CC7E-F996-411E-AFD6-72673A826549}
{68548ECD-222C-40C8-B975-46A17E5D5038} = {3D04C4DC-6F8E-4326-9569-92F3E26C6EEB}
{1C3FD988-6CBF-4EAE-A78D-F7D8BA085E0D} = {01F3CC7E-F996-411E-AFD6-72673A826549}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A659CEFB-DDB3-49BE-AEDD-FF2F1B3297DB}
Expand Down
4 changes: 4 additions & 0 deletions src/DotNetty.Buffers/Properties/Friends.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@
[assembly: InternalsVisibleTo("DotNetty.Codecs.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d9782d5a0b850f230f71e06de2e101d8441d83e15eef715837eee38fdbf5cb369b41ec36e6e7668c18cbb09e5419c179360461e740c1cce6ffbdcf81f245e1e705482797fe42aff2d31ecd72ea87362ded3c14066746fbab4a8e1896f8b982323c84e2c1b08407c0de18b7feef1535fb972a3b26181f5a304ebd181795a46d8f")]
[assembly: InternalsVisibleTo("DotNetty.Microbench, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d9782d5a0b850f230f71e06de2e101d8441d83e15eef715837eee38fdbf5cb369b41ec36e6e7668c18cbb09e5419c179360461e740c1cce6ffbdcf81f245e1e705482797fe42aff2d31ecd72ea87362ded3c14066746fbab4a8e1896f8b982323c84e2c1b08407c0de18b7feef1535fb972a3b26181f5a304ebd181795a46d8f")]
[assembly: InternalsVisibleTo("DotNetty.Buffers.ReaderWriter.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d9782d5a0b850f230f71e06de2e101d8441d83e15eef715837eee38fdbf5cb369b41ec36e6e7668c18cbb09e5419c179360461e740c1cce6ffbdcf81f245e1e705482797fe42aff2d31ecd72ea87362ded3c14066746fbab4a8e1896f8b982323c84e2c1b08407c0de18b7feef1535fb972a3b26181f5a304ebd181795a46d8f")]
// Allow the generation of mocks for internal types
// http://stackoverflow.com/questions/30089042/typeloadexception-using-moq-on-internal-interface-in-signed-assembly
// https://github.com/Moq/moq4/wiki/Quickstart
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
4 changes: 4 additions & 0 deletions src/DotNetty.Codecs.Http/Properties/Friends.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@

[assembly: InternalsVisibleTo("DotNetty.Codecs.Http.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d9782d5a0b850f230f71e06de2e101d8441d83e15eef715837eee38fdbf5cb369b41ec36e6e7668c18cbb09e5419c179360461e740c1cce6ffbdcf81f245e1e705482797fe42aff2d31ecd72ea87362ded3c14066746fbab4a8e1896f8b982323c84e2c1b08407c0de18b7feef1535fb972a3b26181f5a304ebd181795a46d8f")]
[assembly: InternalsVisibleTo("DotNetty.Microbench, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d9782d5a0b850f230f71e06de2e101d8441d83e15eef715837eee38fdbf5cb369b41ec36e6e7668c18cbb09e5419c179360461e740c1cce6ffbdcf81f245e1e705482797fe42aff2d31ecd72ea87362ded3c14066746fbab4a8e1896f8b982323c84e2c1b08407c0de18b7feef1535fb972a3b26181f5a304ebd181795a46d8f")]
// Allow the generation of mocks for internal types
// http://stackoverflow.com/questions/30089042/typeloadexception-using-moq-on-internal-interface-in-signed-assembly
// https://github.com/Moq/moq4/wiki/Quickstart
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
4 changes: 4 additions & 0 deletions src/DotNetty.Codecs.Mqtt/Properties/Friends.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("DotNetty.Codecs.Mqtt.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d9782d5a0b850f230f71e06de2e101d8441d83e15eef715837eee38fdbf5cb369b41ec36e6e7668c18cbb09e5419c179360461e740c1cce6ffbdcf81f245e1e705482797fe42aff2d31ecd72ea87362ded3c14066746fbab4a8e1896f8b982323c84e2c1b08407c0de18b7feef1535fb972a3b26181f5a304ebd181795a46d8f")]
// Allow the generation of mocks for internal types
// http://stackoverflow.com/questions/30089042/typeloadexception-using-moq-on-internal-interface-in-signed-assembly
// https://github.com/Moq/moq4/wiki/Quickstart
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
4 changes: 4 additions & 0 deletions src/DotNetty.Common/Properties/Friends.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("DotNetty.Common.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d9782d5a0b850f230f71e06de2e101d8441d83e15eef715837eee38fdbf5cb369b41ec36e6e7668c18cbb09e5419c179360461e740c1cce6ffbdcf81f245e1e705482797fe42aff2d31ecd72ea87362ded3c14066746fbab4a8e1896f8b982323c84e2c1b08407c0de18b7feef1535fb972a3b26181f5a304ebd181795a46d8f")]
// Allow the generation of mocks for internal types
// http://stackoverflow.com/questions/30089042/typeloadexception-using-moq-on-internal-interface-in-signed-assembly
// https://github.com/Moq/moq4/wiki/Quickstart
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
148 changes: 148 additions & 0 deletions src/DotNetty.NetUV/Buffers/ReadableBuffer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
/*
* Copyright (c) Johnny Z. All rights reserved.
*
* https://github.com/StormHub/NetUV
*
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*
* Copyright (c) 2020 The Dotnetty-Span-Fork Project (cuteant@outlook.com)
*
* https://github.com/cuteant/dotnetty-span-fork
*
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/

namespace DotNetty.Buffers
{
using System;
using System.Collections.Generic;
using System.Text;
using DotNetty.NetUV;

public readonly struct ReadableBuffer : IDisposable
{
internal static readonly ReadableBuffer Empty = new ReadableBuffer(Unpooled.Empty, 0);

private readonly IByteBuffer _buffer;

internal ReadableBuffer(IByteBuffer buffer, int count)
{
if (buffer is null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.buffer); }
if ((uint)count > SharedConstants.TooBigOrNegative) { ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.count); }

_buffer = buffer;
_buffer.SetWriterIndex(_buffer.WriterIndex + count);
}

private ReadableBuffer(IByteBuffer buffer)
{
if (buffer is null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.buffer); }

_buffer = buffer;
}

public readonly int Count => _buffer.ReadableBytes;

public readonly IByteBuffer Buffer => _buffer;

public ReadableBuffer Retain()
{
_buffer.Retain();
return this;
}

public static ReadableBuffer Composite(IEnumerable<ReadableBuffer> buffers)
{
if (buffers is null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.buffers); }

CompositeByteBuffer composite = Unpooled.CompositeBuffer();
foreach (ReadableBuffer buf in buffers)
{
IByteBuffer byteBuffer = buf._buffer;
if (byteBuffer.IsReadable())
{
composite.AddComponent(byteBuffer);
}
}

return new ReadableBuffer(composite);
}

//public string ReadString(Encoding encoding, byte[] separator)
//{
// Contract.Requires(encoding is object);
// Contract.Requires(separator is object && separator.Length > 0);

// int readableBytes = this.buffer.ReadableBytes;
// if (readableBytes == 0)
// {
// return string.Empty;
// }

// IByteBuffer buf = Unpooled.WrappedBuffer(separator);
// return ByteBufferUtil.ReadString(this.buffer, buf, encoding);
//}

public string ReadString(Encoding encoding) => _buffer.ReadString(_buffer.ReadableBytes, encoding);

public string ReadString(int length, Encoding encoding) => _buffer.ReadString(length, encoding);

public bool ReadBoolean() => _buffer.ReadBoolean();

public byte ReadByte() => _buffer.ReadByte();

public sbyte ReadSByte() => unchecked((sbyte)_buffer.ReadByte());

public short ReadInt16() => _buffer.ReadShort();

public short ReadInt16LE() => _buffer.ReadShortLE();

public ushort ReadUInt16() => _buffer.ReadUnsignedShort();

public ushort ReadUInt16LE() => _buffer.ReadUnsignedShortLE();

public int ReadInt24() => _buffer.ReadMedium();

public int ReadInt24LE() => _buffer.ReadMediumLE();

public uint ReadUInt24() => unchecked((uint)_buffer.ReadUnsignedMedium());

public uint ReadUInt24LE() => unchecked((uint)_buffer.ReadUnsignedMediumLE());

public int ReadInt32() => _buffer.ReadInt();

public int ReadInt32LE() => _buffer.ReadIntLE();

public uint ReadUInt32() => _buffer.ReadUnsignedInt();

public uint ReadUInt32LE() => _buffer.ReadUnsignedIntLE();

public long ReadInt64() => _buffer.ReadLong();

public long ReadInt64LE() => _buffer.ReadLongLE();

public ulong ReadUInt64() => unchecked((ulong)_buffer.ReadLong());

public ulong ReadUInt64LE() => unchecked((ulong)_buffer.ReadLongLE());

public float ReadFloat() => _buffer.ReadFloat();

public float ReadFloatLE() => _buffer.ReadFloatLE();

public double ReadDouble() => _buffer.ReadDouble();

public double ReadDoubleLE() => _buffer.ReadDoubleLE();

public void ReadBytes(byte[] destination) => _buffer.ReadBytes(destination);

public void ReadBytes(byte[] destination, int length) => _buffer.ReadBytes(destination, 0, length);

public void Dispose()
{
if (_buffer.IsAccessible)
{
_buffer.Release();
}
}
}
}
Loading