using System; using System.Collections; using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; using System.Threading; namespace Interop.LmxProxy; internal sealed class _ILMXProxyServerEvents2_EventProvider : _ILMXProxyServerEvents2_Event, IDisposable { private WeakReference m_wkConnectionPointContainer; private ArrayList m_aEventSinkHelpers; private IConnectionPoint m_ConnectionPoint; private void Init() { IConnectionPoint ppCP = null; Guid riid = new Guid(new byte[16] { 196, 111, 10, 199, 239, 9, 49, 79, 136, 116, 160, 73, 254, 232, 122, 149 }); ((IConnectionPointContainer)m_wkConnectionPointContainer.Target).FindConnectionPoint(ref riid, out ppCP); m_ConnectionPoint = ppCP; m_aEventSinkHelpers = new ArrayList(); } public void add_OnBufferedDataChange(_ILMXProxyServerEvents2_OnBufferedDataChangeEventHandler P_0) { bool lockTaken = default(bool); try { Monitor.Enter(this, ref lockTaken); if (m_ConnectionPoint == null) { Init(); } _ILMXProxyServerEvents2_SinkHelper iLMXProxyServerEvents2_SinkHelper = new _ILMXProxyServerEvents2_SinkHelper(); int pdwCookie = 0; m_ConnectionPoint.Advise(iLMXProxyServerEvents2_SinkHelper, out pdwCookie); iLMXProxyServerEvents2_SinkHelper.m_dwCookie = pdwCookie; iLMXProxyServerEvents2_SinkHelper.m_OnBufferedDataChangeDelegate = P_0; m_aEventSinkHelpers.Add(iLMXProxyServerEvents2_SinkHelper); } finally { if (lockTaken) { Monitor.Exit(this); } } } public void remove_OnBufferedDataChange(_ILMXProxyServerEvents2_OnBufferedDataChangeEventHandler P_0) { bool lockTaken = default(bool); try { Monitor.Enter(this, ref lockTaken); if (m_aEventSinkHelpers == null) { return; } int count = m_aEventSinkHelpers.Count; int num = 0; if (0 >= count) { return; } do { _ILMXProxyServerEvents2_SinkHelper iLMXProxyServerEvents2_SinkHelper = (_ILMXProxyServerEvents2_SinkHelper)m_aEventSinkHelpers[num]; if (iLMXProxyServerEvents2_SinkHelper.m_OnBufferedDataChangeDelegate != null && ((iLMXProxyServerEvents2_SinkHelper.m_OnBufferedDataChangeDelegate.Equals(P_0) ? 1u : 0u) & 0xFFu) != 0) { m_aEventSinkHelpers.RemoveAt(num); m_ConnectionPoint.Unadvise(iLMXProxyServerEvents2_SinkHelper.m_dwCookie); if (count <= 1) { Marshal.ReleaseComObject(m_ConnectionPoint); m_ConnectionPoint = null; m_aEventSinkHelpers = null; } break; } num++; } while (num < count); } finally { if (lockTaken) { Monitor.Exit(this); } } } public _ILMXProxyServerEvents2_EventProvider(object P_0) { //Error decoding local variables: Signature type sequence must have at least one element. m_wkConnectionPointContainer = new WeakReference((IConnectionPointContainer)P_0, trackResurrection: false); } public void Finalize() { bool lockTaken = default(bool); try { Monitor.Enter(this, ref lockTaken); if (m_ConnectionPoint == null) { return; } int count = m_aEventSinkHelpers.Count; int num = 0; if (0 < count) { do { _ILMXProxyServerEvents2_SinkHelper iLMXProxyServerEvents2_SinkHelper = (_ILMXProxyServerEvents2_SinkHelper)m_aEventSinkHelpers[num]; m_ConnectionPoint.Unadvise(iLMXProxyServerEvents2_SinkHelper.m_dwCookie); num++; } while (num < count); } Marshal.ReleaseComObject(m_ConnectionPoint); } catch (Exception) { } finally { if (lockTaken) { Monitor.Exit(this); } } } public void Dispose() { //Error decoding local variables: Signature type sequence must have at least one element. Finalize(); GC.SuppressFinalize(this); } }