private void RemoveStreamFromProviders(EventProviderDataStream streamToRemove) { foreach (WeakReference reference in s_providers) { EventProviderBase target = reference.Target as EventProviderBase; if (target != null) { if (target.m_OutputStreams.m_MasterStream == streamToRemove) { target.m_OutputStreams = target.m_OutputStreams.m_Next; } else { EventProviderDataStream outputStreams = target.m_OutputStreams; while (true) { EventProviderDataStream next = outputStreams.m_Next; if (next == null) { break; } if (next.m_MasterStream == streamToRemove) { outputStreams.m_Next = next.m_Next; break; } outputStreams = next; } } } } }
public static EventProviderDataStream Register(Action <EventWrittenEventArgs> callBack) { lock (EventProviderStreamsLock) { EventProviderDataStream masterStream = new EventProviderDataStream(callBack, s_Streams, null, null); s_Streams = masterStream; foreach (WeakReference reference in s_providers) { EventProviderBase target = reference.Target as EventProviderBase; if (target != null) { target.m_OutputStreams = new EventProviderDataStream(callBack, target.m_OutputStreams, new bool[target.EventIdLimit], masterStream); } } return(masterStream); } }
internal static void AddProvider(EventProviderBase newProvider) { lock (EventProviderStreamsLock) { if (s_providers == null) { s_providers = new List<WeakReference>(2); } int count = -1; if ((s_providers.Count % 0x40) == 0x3f) { for (int i = 0; i < s_providers.Count; i++) { WeakReference reference = s_providers[i]; if (!reference.IsAlive) { count = i; reference.Target = newProvider; break; } } } if (count < 0) { count = s_providers.Count; s_providers.Add(new WeakReference(newProvider)); } newProvider.m_id = count; for (EventProviderDataStream stream = s_Streams; stream != null; stream = stream.m_Next) { newProvider.m_OutputStreams = new EventProviderDataStream(stream.m_Callback, newProvider.m_OutputStreams, new bool[newProvider.EventIdLimit], stream); } EventHandler<EventProviderCreatedEventArgs> handler = s_EventProviderCreated; if (handler != null) { EventProviderCreatedEventArgs e = new EventProviderCreatedEventArgs { Provider = newProvider }; handler(null, e); } } }
internal static void AddProvider(EventProviderBase newProvider) { lock (EventProviderStreamsLock) { if (s_providers == null) { s_providers = new List <WeakReference>(2); } int count = -1; if ((s_providers.Count % 0x40) == 0x3f) { for (int i = 0; i < s_providers.Count; i++) { WeakReference reference = s_providers[i]; if (!reference.IsAlive) { count = i; reference.Target = newProvider; break; } } } if (count < 0) { count = s_providers.Count; s_providers.Add(new WeakReference(newProvider)); } newProvider.m_id = count; for (EventProviderDataStream stream = s_Streams; stream != null; stream = stream.m_Next) { newProvider.m_OutputStreams = new EventProviderDataStream(stream.m_Callback, newProvider.m_OutputStreams, new bool[newProvider.EventIdLimit], stream); } EventHandler <EventProviderCreatedEventArgs> handler = s_EventProviderCreated; if (handler != null) { EventProviderCreatedEventArgs e = new EventProviderCreatedEventArgs { Provider = newProvider }; handler(null, e); } } }
public void SendCommand(Guid providerGuid, bool enable, EventLevel level, EventKeywords matchAnyKeyword, ControllerCommand command, IDictionary <string, string> commandArguments) { List <EventProviderBase> list = new List <EventProviderBase>(); lock (EventProviderStreamsLock) { foreach (WeakReference reference in s_providers) { EventProviderBase target = reference.Target as EventProviderBase; if ((target != null) && ((target.Guid == providerGuid) || (providerGuid == Guid.Empty))) { list.Add(target); } } } foreach (EventProviderBase base3 in list) { base3.SendCommand(this, enable, level, matchAnyKeyword, command, commandArguments); } }
public OverideEventProvider(EventProviderBase eventProvider) { this.m_eventProviderBase = eventProvider; }
public OverideEventProvider(EventProviderBase eventProvider) { this.m_eventProviderBase = eventProvider; }
internal EventWrittenEventArgs(EventProviderBase providerBase) { m_providerBase = providerBase; }
/// <summary> /// This routine adds this to the global list of providers, it also assigns the ID to the /// provider (which is simply the oridinal in the global list) /// </summary> /// <param name="newProvider"></param> internal static void AddProvider(EventProviderBase newProvider) { lock (EventProviderStreamsLock) { if (s_providers == null) s_providers = new List<WeakReference>(2); // Periodically search the list for existing entries to reuse, this avoids // unbounded memory use if we keep recycling providers (an unlikely thing). int newIndex = -1; if (s_providers.Count % 64 == 63) { for (int i = 0; i < s_providers.Count; i++) { WeakReference weakRef = s_providers[i]; if (!weakRef.IsAlive) { newIndex = i; weakRef.Target = newProvider; break; } } } if (newIndex < 0) { newIndex = s_providers.Count; s_providers.Add(new WeakReference(newProvider)); } newProvider.m_id = newIndex; // Add every existing outputStream to the new Provider for (EventProviderDataStream outputStream = s_Streams; outputStream != null; outputStream = outputStream.m_Next) newProvider.m_OutputStreams = new EventProviderDataStream(outputStream.m_Callback, newProvider.m_OutputStreams, new bool[newProvider.EventIdLimit], outputStream); // Put in a local to avoid ---- with null check. EventHandler<EventProviderCreatedEventArgs> callback = s_EventProviderCreated; if (callback != null) callback(null, new EventProviderCreatedEventArgs { Provider = newProvider }); } }
/// <summary> /// A small integer (suitable for indexing in an array) identifying this provider. It is unique /// per-appdomain. This allows the callback registered in 'Register' to efficiently attach addition /// information to a provider. /// </summary> public static int ProviderId(EventProviderBase provider) { return provider.m_id; }
public static int ProviderId(EventProviderBase provider) { return(provider.m_id); }
internal EventWrittenEventArgs(EventProviderBase providerBase) { this.m_providerBase = providerBase; }