コード例 #1
0
        /// <inheritdoc/>
        public override byte[] Serialize <T>(T value)
        {
            var serializer = _cache.GetSerializer(value.GetType());
            var buffer     = StringBuilderPool.Lease();

            using (var stringWriter = new StringWriter(buffer))
            {
                var writer = new SimpleJsonWriter(stringWriter);
                serializer.Serialize(value, writer);

                var bytes = Encoding.UTF8.GetBytes(buffer.ToString());
                StringBuilderPool.Return(buffer);
                return(bytes);
            }
        }