public void Serialize(CueSerializeContext context) { if (context.Version >= 4) { context.bw.Write(path); } else { throw new NotSupportedException("Legacy formats are not supported."); } }
public void Serialize(CueSerializeContext context) { context.bw.WriteNullableStringNonBlank(friendlyName); context.bw.Write((byte)type); context.bw.Write(radius); context.bw.Write(pitch); context.bw.Write(pan); context.bw.Write(volume); context.bw.Write(sounds.Count); foreach (var sound in sounds) { context.WriteSound(sound); } if (context.Version >= 2) { context.bw.WriteNullableSingle(minPitch); context.bw.WriteNullableSingle(maxPitch); } }
/// <summary>Check that an Cue round-trips through serialization cleanly</summary> public void RoundTripCheck() { // Serialize a first time var firstMemoryStream = new MemoryStream(); var firstSerializeContext = new CueSerializeContext(new BinaryWriter(firstMemoryStream)); Serialize(firstSerializeContext); var originalData = firstMemoryStream.ToArray(); // Then deserialize that data var br = new BinaryReader(new MemoryStream(originalData)); var deserializeContext = new CueDeserializeContext(br); var deserialized = new Cue(deserializeContext); // Then serialize that deserialized data and see if it matches var secondMemoryStream = new MemoryCompareStream(originalData); var secondSerializeContext = new CueSerializeContext(new BinaryWriter(secondMemoryStream)); deserialized.Serialize(secondSerializeContext); }