/// <summary> /// Returns the filtered array of the ReceiverInfo instances. /// </summary> /// <param name="arrayOfReceiverInfo">The list of receivers being filtered out.</param> /// <param name="iMessage">The invocation.</param> /// <param name="resultCollector">The Result Collector obtaining the list of receivers. Is used for debugging purposes only.</param> public void GetListOfReceivers(out object[] arrayOfReceiverInfo, IMessage iMessage, ResultCollector resultCollector) { arrayOfReceiverInfo = null; try { using (ReaderAutoLocker reader = new ReaderAutoLocker(this._readerWriterLock)) { // check whether they were cached if (this._cachedReceiversInfoArray == null) { this._cachedReceiversInfoArray = new object[this._receivers.Values.Count]; this._receivers.Values.CopyTo(this._cachedReceiversInfoArray, 0); } // get the cached array arrayOfReceiverInfo = this._cachedReceiversInfoArray; // and drive it thru the filter IMulticastFilter iMulticastFilter = Dispatcher.GetCurrentFilter(); if (iMulticastFilter == null) { iMulticastFilter = this.IMulticastFilter; } if (iMulticastFilter != null) { // LOG: BinaryLogWriter binaryLogWriter = GenuineLoggingServices.BinaryLogWriter; if (binaryLogWriter != null && binaryLogWriter[LogCategory.BroadcastEngine] > 0) { binaryLogWriter.WriteBroadcastEngineEvent(LogCategory.BroadcastEngine, "Dispatcher.GetListOfReceivers", LogMessageType.BroadcastFilterCalled, null, null, null, null, GenuineUtility.CurrentThreadId, Thread.CurrentThread.Name, null, null, false, this, resultCollector, false, null, iMulticastFilter.GetType().ToString(), null, "The broadcast filter is called. The type of the filter: {0}.", iMulticastFilter.GetType().ToString()); } arrayOfReceiverInfo = iMulticastFilter.GetReceivers(arrayOfReceiverInfo, iMessage); } } } catch (Exception ex) { // LOG: BinaryLogWriter binaryLogWriter = GenuineLoggingServices.BinaryLogWriter; if (binaryLogWriter != null && binaryLogWriter[LogCategory.BroadcastEngine] > 0) { binaryLogWriter.WriteBroadcastEngineEvent(LogCategory.BroadcastEngine, "Dispatcher.GetListOfReceivers", LogMessageType.BroadcastFilterCalled, ex, null, null, null, GenuineUtility.CurrentThreadId, Thread.CurrentThread.Name, null, null, false, this, resultCollector, false, null, null, null, "The exception occurred while calling the broadcast filter."); } } }
/// <summary> /// Specifies the filter which will be used in the current thread. /// Returns the preceding filter specified in the current thread. /// </summary> /// <param name="iMulticastFilter">The filter being set.</param> /// <returns>The previous filter.</returns> public static IMulticastFilter SetCurrentFilter(IMulticastFilter iMulticastFilter) { LocalDataStoreSlot localDataStoreSlot = Thread.GetNamedDataSlot(OccupiedThreadSlots.DispatcherFilterUsed); object previousDataSlotValue = Thread.GetData(localDataStoreSlot); Thread.SetData(localDataStoreSlot, iMulticastFilter); return(previousDataSlotValue as IMulticastFilter); }
/// <summary> /// Constructs an instance of the DispatcherFilterKeeper class. /// </summary> /// <param name="iMulticastFilter">The filter supporting IMulticastFilter interface.</param> public DispatcherFilterKeeper(IMulticastFilter iMulticastFilter) { this._previousIMulticastFilter = Dispatcher.SetCurrentFilter(iMulticastFilter); }
/// <summary> /// Constructs an instance of the DispatcherFilterKeeper class. /// </summary> /// <param name="iMulticastFilter">The filter supporting IMulticastFilter interface.</param> public DispatcherFilterKeeper(IMulticastFilter iMulticastFilter) { this._previousIMulticastFilter = Dispatcher.SetCurrentFilter(iMulticastFilter); }
/// <summary> /// Specifies the filter which will be used in the current thread. /// Returns the preceding filter specified in the current thread. /// </summary> /// <param name="iMulticastFilter">The filter being set.</param> /// <returns>The previous filter.</returns> public static IMulticastFilter SetCurrentFilter(IMulticastFilter iMulticastFilter) { LocalDataStoreSlot localDataStoreSlot = Thread.GetNamedDataSlot(OccupiedThreadSlots.DispatcherFilterUsed); object previousDataSlotValue = Thread.GetData(localDataStoreSlot); Thread.SetData(localDataStoreSlot, iMulticastFilter); return previousDataSlotValue as IMulticastFilter; }