예제 #1
0
        public byte[] ToBytes(JsonComposeSettings settings)
        {
#if NET45
            using (var stream = new MemoryStream())
#else
            using (var stream = new MyMemoryStream())
#endif
            {
                ToStream(stream, settings);
                stream.Position = 0;
                var bytes = stream.ToArray();
#if !NET45
                stream.ReallyClose();
#endif
                return(bytes);
            }
        }
예제 #2
0
        public string ToString(JsonComposeSettings settings)
        {
#if NET45
            using (var stream = new MemoryStream())
#else
            using (var stream = new MyMemoryStream())
#endif
            {
                ToStream(stream, settings);
                stream.Position = 0;
                var result = settings.Encoding.GetString(stream.ToArray());
#if !NET45
                stream.ReallyClose();
#endif
                return(result);
            }
        }