示例#1
0
        public static Utf8String Quote(Utf8String s)
        {
            var sb = new BytesStore(s.ByteLength);

            Quote(s, sb);
            return(new Utf8String(sb.Bytes));
        }
示例#2
0
        static void SerializeValue <T>(T value, string json)
        {
            var b = new BytesStore();
            var f = new JsonFormatter(b);

            f.Serialize(value);
            Assert.AreEqual(json, new Utf8String(b.Bytes).ToString());
        }
示例#3
0
        public void ArrayStoreTest()
        {
            var store = new BytesStore(1);

            store.WriteValues(1, 2, 3);
            Assert.True(new Byte[] { 1, 2, 3 }.SequenceEqual(store.Bytes.ToEnumerable()));

            store.Write(4);
            Assert.True(new Byte[] { 1, 2, 3, 4 }.SequenceEqual(store.Bytes.ToEnumerable()));

            store.Clear();
            store.Write(5);
            Assert.True(new Byte[] { 5 }.SequenceEqual(store.Bytes.ToEnumerable()));
        }
示例#4
0
        public static Utf8String Unquote(Utf8String src)
        {
            var count = Unquote(src, null);

            if (count == src.ByteLength - 2)
            {
                return(src.Subbytes(1, src.ByteLength - 2));
            }
            else
            {
                var sb = new BytesStore(count);
                Unquote(src, sb);
                return(new Utf8String(sb.Bytes));
            }
        }