예제 #1
0
파일: Sound.cs 프로젝트: pvmm/Pixel3D
 public void Serialize(CueSerializeContext context)
 {
     if (context.Version >= 4)
     {
         context.bw.Write(path);
     }
     else
     {
         throw new NotSupportedException("Legacy formats are not supported.");
     }
 }
예제 #2
0
 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);
     }
 }
예제 #3
0
        /// <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);
        }