/// <summary> /// Initializes the entry as an hidden error head (the first time an error occcurs and no event entry is created /// for the event). This entry is not visible (it is not emitted as a log event), it is here to handle the /// potential list of errors that the event will raise. /// </summary> /// <param name="lsn"></param> /// <param name="depth"></param> /// <param name="e"></param> /// <param name="firstOne"></param> internal void InitError(int lsn, int depth, EventInfo e, LogEventEntryError firstOne) { LSN = lsn; _depth = depth; _event = e; _errorCount = -1; _firstError = _lastError = firstOne; }
IEnumerator <ILogEventError> IEnumerable <ILogEventError> .GetEnumerator() { LogEventEntryError l = _firstError; while (l != null) { yield return(l); l = l._nextError; } }
/// <summary> /// Called whenever the recipient of an event raises an exception and the event log already exists. /// This appends the error to the error list of the event entry. /// </summary> /// <param name="ee">Existing event log entry.</param> /// <param name="target">Culprit method.</param> /// <param name="ex">Exception raised by the culprit method.</param> internal void LogEventError(LogEventEntry ee, MethodInfo target, Exception ex) { LogEventEntryError l = new LogEventEntryError(++_nextLSN, ee, target, ex); ee.AddError(l); EventHandler <LogEventArgs> h = EventCreated; if (h != null) { h(_eventSender, l); } else { _untrackedErrors.Add(l); } }
internal void AddError(LogEventEntryError l) { if (_errorCount > 0) { ++_errorCount; } else { --_errorCount; } if (_lastError != null) { _lastError._nextError = l; } else { _firstError = l; } _lastError = l; }
/// <summary> /// Called whenever the recipient of an event raises an exception and the event is not /// yet logged (no <see cref="LogEventEntry"/> exists). This creates the entry for the event /// and the associated error. /// </summary> /// <param name="e">The reflected event info.</param> /// <param name="target">Culprit method.</param> /// <param name="ex">Exception raised by the culprit method.</param> /// <returns>The created event entry that holds the error.</returns> internal LogEventEntry LogEventError(EventInfo e, MethodInfo target, Exception ex) { // This LogEventEntry is an hidden one. We do not emit it. LogEventEntry ee = new LogEventEntry(); LogEventEntryError l = new LogEventEntryError(++_nextLSN, ee, target, ex); ee.InitError(++_nextLSN, _currentDepth, e, l); // Emits the error. EventHandler <LogEventArgs> h = EventCreated; if (h != null) { h(_eventSender, l); } else { _untrackedErrors.Add(l); } return(ee); }
bool IReadOnlyCollection <ILogEventError> .Contains(object o) { LogEventEntryError e = o as LogEventEntryError; return(e != null && e.OtherErrors == this); }