/// <summary> /// Releases the unmanaged resources used by the <see cref="WavInputAdapter"/> object and optionally releases the managed resources. /// </summary> /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param> protected override void Dispose(bool disposing) { if (!m_disposed) { try { if (disposing) { if ((object)m_dataReader != null) { m_dataReader.Close(); m_dataReader.Dispose(); m_dataReader = null; } if ((object)m_dataCache != null) { m_dataCache.Dispose(); } } } finally { m_disposed = true; // Prevent duplicate dispose. base.Dispose(disposing); // Call base class Dispose(). } } }
/// <summary> /// Releases the unmanaged resources used by the <see cref="UnsynchronizedClientSubscription"/> object and optionally releases the managed resources. /// </summary> /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param> protected override void Dispose(bool disposing) { if (!m_disposed) { try { if (disposing) { // Remove reference to parent m_parent = null; // Dispose base time rotation timer if ((object)m_baseTimeRotationTimer != null) { m_baseTimeRotationTimer.Dispose(); m_baseTimeRotationTimer = null; } if ((object)m_workingBuffer != null) { m_workingBuffer.Dispose(); } // Dispose Iaon session this.DisposeTemporalSession(ref m_iaonSession); } } finally { m_disposed = true; // Prevent duplicate dispose. base.Dispose(disposing); // Call base class Dispose(). } } }
/// <summary> /// Serializes an <see cref="Object"/>. /// </summary> /// <typeparam name="T"><see cref="Type"/> of the <paramref name="serializableObject"/>.</typeparam> /// <param name="serializableObject"><see cref="Object"/> to be serialized.</param> /// <param name="serializationFormat"><see cref="SerializationFormat"/> in which the <paramref name="serializableObject"/> is to be serialized.</param> /// <returns>An <see cref="Array"/> of <see cref="Byte"/> of the serialized <see cref="Object"/>.</returns> /// <exception cref="ArgumentNullException"><paramref name="serializableObject"/> is null.</exception> /// <exception cref="NotSupportedException">Specified <paramref name="serializationFormat"/> is not supported.</exception> public static byte[] Serialize <T>(T serializableObject, SerializationFormat serializationFormat) { // FYI, using statement will not work here as this creates a read-only variable that cannot be passed by reference Stream stream = null; try { stream = new BlockAllocatedMemoryStream(); Serialize(serializableObject, serializationFormat, stream); return(((BlockAllocatedMemoryStream)stream).ToArray()); } finally { stream?.Dispose(); } }