Esempio n. 1
0
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            lock (this)
            {
                if (!Disposed)
                {
                    Disposed = true;
                    GC.SuppressFinalize(this);

                    if (FMemoryStream != null)
                    {
                        FMemoryStream.Close();
                        FMemoryStream.Dispose();
                        FMemoryStream = null;
                    }

                    if (FWriter != null)
                    {
                        FWriter.Close();
                        FWriter.Dispose();
                        FWriter = null;
                    }

                    if (FReader != null)
                    {
                        FReader.Close();
                        FReader.Dispose();
                        FReader = null;
                    }
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FastBinaryFormatter"/> class.
 /// </summary>
 public FastBinaryFormatter()
 {
     Disposed      = false;
     FLengthBuffer = new byte[Marshal.SizeOf(typeof(int))];
     FCopyBuffer   = new byte[STREAM_MAX_CAPACITY];
     FMemoryStream = new MemoryStream(STREAM_MAX_CAPACITY);
     FWriter       = new FastBinaryWriter(FMemoryStream);
     FReader       = new FastBinaryReader(FMemoryStream);
 }
Esempio n. 3
0
 void IFastBinarySerializable.WriteData(FastBinaryWriter writer, object additonalInfo)
 {
     writer.Write(Items.Cast <IFastBinarySerializable>().ToArray());
 }
Esempio n. 4
0
 /// <summary>
 /// Writes the data.
 /// </summary>
 /// <param name="writer">The writer.</param>
 /// <param name="additionalInfo">The additional information.</param>
 public virtual void WriteData(FastBinaryWriter writer, object additionalInfo)
 {
     writer.WriteByteArray(ObjectData);
 }