public static ComEventsSink?Remove(ComEventsSink sinks, ComEventsSink sink) { Debug.Assert(sinks != null, "removing event sink from empty sinks collection"); Debug.Assert(sink != null, "specify event sink is null"); ComEventsSink?toReturn = sinks; if (sink == sinks) { toReturn = sinks._next; } else { ComEventsSink?current = sinks; while (current != null && current._next != sink) { current = current._next; } if (current != null) { current._next = sink._next; } } sink.Unadvise(); return(toReturn); }
public static ComEventsSink FromRuntimeCallableWrapper(object rcw, Guid sourceIid, bool createIfNotFound) { List <ComEventsSink> comEventSinks = ComEventSinksContainer.FromRuntimeCallableWrapper(rcw, createIfNotFound); if (comEventSinks == null) { return(null); } ComEventsSink comEventSink = null; lock (comEventSinks) { foreach (ComEventsSink sink in comEventSinks) { if (sink._iidSourceItf == sourceIid) { comEventSink = sink; break; } if (sink._iidSourceItf == Guid.Empty) { // we found a ComEventSink object that // was previously disposed. Now we will reuse it. sink.Initialize(rcw, sourceIid); comEventSink = sink; } } if (comEventSink == null && createIfNotFound) { comEventSink = new ComEventsSink(rcw, sourceIid); comEventSinks.Add(comEventSink); } } return(comEventSink); }
public static ComEventsSink Add(ComEventsSink?sinks, ComEventsSink sink) { sink._next = sinks; return(sink); }