private static void Wrap(StreamWriter w, StreamReader r, string path) { var mcc = CodecWithPath(path); if (mcc == null) { throw new Exception($"unknown codec {path}"); } var hdrs = Encoding.UTF8.GetString(mcc.Header); Action <ICodec, ICodec> wrapRT = (c, mc) => { var v = c.Decoder(r.BaseStream).Decode <dynamic>(); mc.Encoder(w.BaseStream).Encode(v); }; if (hdrs == JsonCodec.HeaderMsgioPath) { wrapRT(JsonCodec.CreateCodec(true), mcc); } else if (hdrs == JsonCodec.HeaderPath) { wrapRT(JsonCodec.CreateCodec(false), mcc); } else if (hdrs == CborCodec.HeaderPath) { wrapRT(CborCodec.CreateCodec(), mcc); } else { throw new Exception($"wrap unsupported for codec {hdrs}"); } }
public void JsonCodecWithoutMsgIoRoundTrip() => MulticodecRoundTrip(JsonCodec.CreateCodec(false));
public void JsonCodecWithMsgIoRoundTrip() => MulticodecRoundTrip(JsonCodec.CreateCodec(true));
public Task JsonCodecWithoutMsgIoRoundTripMany_Async() => MulticodecRoundTripManyAsync(JsonCodec.CreateCodec(false));
public Task JsonCodecWithMsgIoRoundTrip_Async() => MulticodecRoundTripAsync(JsonCodec.CreateCodec(true));