Beispiel #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}");
            }
        }
Beispiel #2
0
 public Task CBORCodecRoundTripMany_Async() => MulticodecRoundTripManyAsync(CborCodec.CreateCodec());
Beispiel #3
0
 public void CBORCodecRoundTripMany() => MulticodecRoundTripMany(CborCodec.CreateCodec());
 public Task CBORCodecRoundTripNested_Async() => MulticodecRoundTripNestedAsync(CborCodec.CreateCodec());
 public void CBORCodecRoundTripNested() => MulticodecRoundTripNested(CborCodec.CreateCodec());