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); } }
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); } }