1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-08-20 12:53:02 +00:00

Feature/protobuf (#243)

Protobuf implementation
This commit is contained in:
Jan Korf
2025-07-14 10:56:18 +02:00
committed by GitHub
parent 0e7d49991a
commit 96f23f163d
20 changed files with 992 additions and 55 deletions
+6 -2
View File
@@ -603,12 +603,16 @@ namespace CryptoExchange.Net.Clients
{
if (contentType == Constants.JsonContentHeader)
{
var serializer = CreateSerializer();
if (serializer is not IStringMessageSerializer stringSerializer)
throw new InvalidOperationException("Non-string message serializer can't get serialized request body");
// Write the parameters as json in the body
string stringData;
if (parameters.Count == 1 && parameters.TryGetValue(Constants.BodyPlaceHolderKey, out object? value))
stringData = CreateSerializer().Serialize(value);
stringData = stringSerializer.Serialize(value);
else
stringData = CreateSerializer().Serialize(parameters);
stringData = stringSerializer.Serialize(parameters);
request.SetContent(stringData, contentType);
}
else if (contentType == Constants.FormContentHeader)
@@ -138,7 +138,7 @@ namespace CryptoExchange.Net.Clients
/// Create a message accessor instance
/// </summary>
/// <returns></returns>
protected internal abstract IByteMessageAccessor CreateAccessor();
protected internal abstract IByteMessageAccessor CreateAccessor(WebSocketMessageType messageType);
/// <summary>
/// Create a serializer instance