public void WritePredefinedBinaryDocument() { using (Stream stream = new MemoryStream()) { TagWriter writer = new BinaryTagWriter(stream); writer.WriteStartDocument(); writer.WriteTag(_predefined); writer.WriteEndDocument(); } }
public void WriteBinaryDocument() { TagCompound root; TagCompound compound; TagCompound child; TagList list; root = new TagCompound(); root.Name = "Level"; root.Value.Add("longTest", 9223372036854775807); root.Value.Add("shortTest", (short)32767); root.Value.Add("stringTest", "HELLO WORLD THIS IS A TEST STRING ÅÄÖ!"); root.Value.Add("floatTest", (float)0.498231471); root.Value.Add("intTest", 2147483647); compound = (TagCompound)root.Value.Add("nested compound test", TagType.Compound); child = (TagCompound)compound.Value.Add("ham", TagType.Compound); child.Value.Add("name", "Hampus"); child.Value.Add("value", (float)0.75); child = (TagCompound)compound.Value.Add("egg", TagType.Compound); child.Value.Add("name", "Eggbert"); child.Value.Add("value", (float)0.5); list = (TagList)root.Value.Add("listTest (long)", TagType.List, TagType.Long); list.Value.Add((long)11); list.Value.Add((long)12); list.Value.Add((long)13); list.Value.Add((long)14); list.Value.Add((long)15); list = (TagList)root.Value.Add("listTest (compound)", TagType.List, TagType.Compound); child = (TagCompound)list.Value.Add(TagType.Compound); child.Value.Add("name", "Compound tag #0"); child.Value.Add("created-on", 1264099775885); child = (TagCompound)list.Value.Add(TagType.Compound); child.Value.Add("name", "Compound tag #1"); child.Value.Add("created-on", 1264099775885); root.Value.Add("byteTest", (byte)127); root.Value.Add("byteArrayTest (the first 1000 values of (n*n*255+n*7)%100, starting with n=0 (0, 62, 34, 16, 8, ...))", SampleByteArray); root.Value.Add("doubleTest", 0.49312871321823148); using (Stream stream = new MemoryStream()) { TagWriter writer; writer = new BinaryTagWriter(stream); writer.WriteStartDocument(); writer.WriteTag(root); writer.WriteEndDocument(); } }