doghappy / socket.io-client-csharp

socket.io-client implemention for .NET
MIT License
730 stars 125 forks source link

IJsonSerializer documentation #179

Closed 23W closed 3 years ago

23W commented 3 years ago

@doghappy Hi, can you please add the documentation how to implement interface IJsonSerializer, or comments for its methods. At least it should be commented in code that method Serialize(T data) always gets an array of objects (or enumerable interface of objects). Because currently it's not obvious.

doghappy commented 3 years ago

Thanks for your suggestion, I changed the method signature:

JsonSerializeResult Serialize(object[] data)

btw, I implement 2 IJsonSerializer:

If you use Newtosoft.Json, you can install SocketIOClient.Newtonsoft.Json from NuGet

var client = new SocketIO(...);
client.JsonSerializer = new NewtonsoftJsonSerializer(client.Options.EIO);

https://github.com/doghappy/socket.io-client-csharp/commit/35e8f3cc5baecc2ffbfab4de137265f743efb34e

23W commented 3 years ago

Thank you, I can not use neither SystemTextJsonSerializer nor NewtonsoftJsonSerializer because have different logic of serialization in my project that's why I need own implementation of IJsonSerializer.