/// <summary> /// Releases the unmanaged resources used by this <see cref="BroEvent"/> object and optionally releases the managed resources. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> protected virtual void Dispose(bool disposing) { if (!m_disposed) { try { #if USE_SAFE_HANDLES if ((object)m_eventPtr != null && !m_eventPtr.IsInvalid()) { m_eventPtr.Dispose(); } #else if (m_eventPtr != IntPtr.Zero) { BroApi.bro_event_free(m_eventPtr); m_eventPtr = IntPtr.Zero; } #endif if (disposing) { m_parameters.Clear(); } } finally { m_disposed = true; // Prevent duplicate dispose. } } }
/// <summary> /// Creates a new <see cref="BroEvent"/> with the specified <paramref name="name"/>. /// </summary> /// <param name="name">Name of the <see cref="BroEvent"/>.</param> /// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c>.</exception> /// <exception cref="OutOfMemoryException">Failed to create Bro event.</exception> public BroEvent(string name) { if ((object)name == null) { throw new ArgumentNullException("name"); } m_eventPtr = BroApi.bro_event_new(name); if (m_eventPtr.IsInvalid()) { throw new OutOfMemoryException("Failed to create Bro event."); } m_name = name; m_parameters = new List <BroValue>(); }