Exemplo n.º 1
0
        public static void StressTest()
        {
            var dict = new Dictionary <string, string>
            {
                { "Key1", "Value1" },
                { "Key2", "Value2" }
            };

            using var writer = new PooledArrayBufferWriter <byte>();
            // serialize dictionary to memory
            using (var output = StreamSource.AsStream(writer))
            {
                DictionarySerializer.Serialize(dict, output);
            }
            // deserialize from memory
            using (var input = StreamSource.AsStream(writer.WrittenArray))
            {
                Equal(dict, DictionarySerializer.Deserialize(input));
            }
        }
Exemplo n.º 2
0
        public static void StressTest()
        {
            var dict = new Dictionary <string, string>
            {
                { "Key1", "Value1" },
                { "Key2", "Value2" }
            };
            var formatter = new BinaryFormatter();

            using var writer = new PooledArrayBufferWriter <byte>();
            // serialize dictionary to memory
            using (var output = StreamSource.AsStream(writer))
            {
                formatter.Serialize(output, dict);
            }
            // deserialize from memory
            using (var input = StreamSource.GetWrittenBytesAsStream(writer))
            {
                Equal(dict, formatter.Deserialize(input));
            }
        }