public static bool TestSerializeDeserialize(JToken root, IPsbStreamSource streamSource, string psbOutPath, TextWriter jsonWriter, TextWriter debugWriter) { using (FileStream fs = File.Create(psbOutPath)) { PsbWriter writer = new PsbWriter(root, streamSource) { Version = 4, Optimize = true }; writer.Write(fs); fs.Flush(); fs.Seek(0, SeekOrigin.Begin); PsbReader reader = new PsbReader(fs, null, debugWriter); reader.Root.WriteTo(new JsonTextWriter(jsonWriter) { Formatting = Formatting.Indented }); return(new JTokenEqualityComparer().Equals(root, reader.Root)); } }
public static bool TestSerializeDeserialize(PsbReader reader, string psbOutPath, TextWriter jsonWriter, TextWriter debugWriter) { using (MemoryStream ms = new MemoryStream()) { PsbWriter writer = new PsbWriter(reader.Root, null) { Version = reader.Version, Optimize = true }; writer.Write(ms); File.WriteAllBytes(psbOutPath, ms.ToArray()); ms.Seek(0, SeekOrigin.Begin); PsbReader newReader = new PsbReader(ms, null, debugWriter); JsonTextWriter jtw = new JsonTextWriter(jsonWriter) { Formatting = Formatting.Indented }; newReader.Root.WriteTo(jtw); return(new JTokenEqualityComparer().Equals(reader.Root, newReader.Root)); } }