/// <inheritdoc/> public void Serialize(IBufferWriter <byte> contentBuffer, JsonRpcMessage message) { if (this.compress) { LZ4MessagePackSerializer.Typeless.Serialize(contentBuffer.AsStream(), message); } else { MessagePackSerializer.Typeless.Serialize(contentBuffer.AsStream(), message); } }
/// <inheritdoc/> public void Serialize(IBufferWriter <byte> contentBuffer, JsonRpcMessage message) { if (message is JsonRpcRequest request && request.Arguments != null && request.ArgumentsList == null && !(request.Arguments is IReadOnlyDictionary <string, object>)) { // This request contains named arguments, but not using a standard dictionary. Convert it to a dictionary so that // the parameters can be matched to the method we're invoking. request.Arguments = GetParamsObjectDictionary(request.Arguments); } if (this.compress) { LZ4MessagePackSerializer.Typeless.Serialize(contentBuffer.AsStream(), message); } else { MessagePackSerializer.Typeless.Serialize(contentBuffer.AsStream(), message); } }
/// <inheritdoc/> public void Serialize(IBufferWriter <byte> contentBuffer, JsonRpcMessage message) { var correctedMessage = ToValidRequest(message); switch (_serializerKind) { case MessagePackSerializerKind.LZ4MessagePackSerializer: LZ4MessagePackSerializer.Serialize(contentBuffer.AsStream(), correctedMessage, _resolver); return; case MessagePackSerializerKind.MessagePackSerializer: MessagePackSerializer.Serialize(contentBuffer.AsStream(), correctedMessage, _resolver); return; default: throw new InvalidOperationException("internal error"); } }
public void Null_Throws() { IBufferWriter <byte> writer = null; Assert.Throws <ArgumentNullException>(() => writer.AsStream()); }