Example #1
0
        public void WriteToFile(BinaryWriter writer)
        {
            bool isBigEndian = false;

            writer.Write((int)bufferType);

            if (buffer != null)
            {
                writer.Write(buffer.Length);
                writer.Write(buffer);
            }
            else
            {
                writer.Write(data.GetSize());

                using (MemoryStream stream = new MemoryStream())
                {
                    data.WriteToFile(stream, isBigEndian);
                    Debug.Assert(data.GetSize() == stream.Length);
                    stream.WriteTo(writer.BaseStream);
                }
            }
        }
Example #2
0
        public void WriteToFile(BinaryWriter writer)
        {
            bool isBigEndian = false;

            writer.Write((int)bufferType);

            if (buffer != null)
            {
                writer.Write(buffer.Length);
                writer.Write(buffer);
            }
            else
            {
                writer.Write(data.GetSize());

                using (MemoryStream stream = new MemoryStream())
                {
                    data.WriteToFile(stream, isBigEndian);
                    Debug.Assert(data.GetSize() == stream.Length, string.Format("We did not reach the end of this stream! BufferType {0}", bufferType));
                    stream.WriteTo(writer.BaseStream);
                }
            }
        }