internal void Dispose( IntPtr pInterface, DetachCallbackEventHandlerDelegate pInvokeDetach) { if (this.Callbacks.IsValueCreated) { foreach (var tuple in this.Callbacks.Value.Values) { pInvokeDetach(pInterface, tuple.Item1); NativeMethods.Inspectable_Release(tuple.Item1); } this.Callbacks.Value.Clear(); } }
internal void RemoveCallbackEventHandler( IntPtr pInterface, DetachCallbackEventHandlerDelegate pInvokeDetach, OnEventHandlerAdapter <T> callback) { Tuple <IntPtr, NativeMethods.OnCallbackEventHandler> tuple; if (!this.Callbacks.Value.TryGetValue(callback, out tuple)) { throw new InvalidOperationException("Callback not registered"); } PInvokeUtils.ThrowIfResult(pInvokeDetach(pInterface, tuple.Item1)); NativeMethods.Inspectable_Release(tuple.Item1); this.Callbacks.Value.Remove(callback); }