예제 #1
0
        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}");
            }
        }
예제 #2
0
 public void JsonCodecWithoutMsgIoRoundTrip() => MulticodecRoundTrip(JsonCodec.CreateCodec(false));
예제 #3
0
 public void JsonCodecWithMsgIoRoundTrip() => MulticodecRoundTrip(JsonCodec.CreateCodec(true));
예제 #4
0
 public Task JsonCodecWithoutMsgIoRoundTripMany_Async() => MulticodecRoundTripManyAsync(JsonCodec.CreateCodec(false));
예제 #5
0
 public Task JsonCodecWithMsgIoRoundTrip_Async() => MulticodecRoundTripAsync(JsonCodec.CreateCodec(true));