Skip to content

Commit d1f7adf

Browse files
committed
#49 OnSubmitted Event Handler
1 parent 2daea2b commit d1f7adf

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

Source/Shared/ExceptionlessClient.cs

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,12 @@ public void SubmitEvent(Event ev, ContextData pluginContextData = null) {
169169
_log.Value.FormattedTrace(typeof(ExceptionlessClient), "Submitting event: type={0}{1}", ev.Type, !String.IsNullOrEmpty(ev.ReferenceId) ? " refid=" + ev.ReferenceId : String.Empty);
170170
_queue.Value.Enqueue(ev);
171171

172-
if (String.IsNullOrEmpty(ev.ReferenceId))
173-
return;
172+
if (!String.IsNullOrEmpty(ev.ReferenceId)) {
173+
_log.Value.FormattedTrace(typeof(ExceptionlessClient), "Setting last reference id '{0}'", ev.ReferenceId);
174+
_lastReferenceIdManager.Value.SetLast(ev.ReferenceId);
175+
}
174176

175-
_log.Value.FormattedTrace(typeof(ExceptionlessClient), "Setting last reference id '{0}'", ev.ReferenceId);
176-
_lastReferenceIdManager.Value.SetLast(ev.ReferenceId);
177+
OnSubmittedEvent(new EventSubmittingEventArgs(this, ev, pluginContextData));
177178
}
178179

179180
/// <summary>Creates a new instance of <see cref="Event" />.</summary>
@@ -225,6 +226,31 @@ protected void OnSubmittingEvent(EventSubmittingEventArgs e) {
225226
}
226227
}
227228

229+
/// <summary>
230+
/// Occurs when the event has been submitted.
231+
/// </summary>
232+
public event EventHandler<EventSubmittingEventArgs> SubmittedEvent;
233+
234+
/// <summary>
235+
/// Raises the <see cref="SubmittedEvent" /> event.
236+
/// </summary>
237+
/// <param name="e">The <see cref="EventSubmittingEventArgs" /> instance containing the event data.</param>
238+
protected void OnSubmittedEvent(EventSubmittingEventArgs e) {
239+
if (SubmittedEvent == null)
240+
return;
241+
242+
var handlers = SubmittedEvent.GetInvocationList();
243+
foreach (var handler in handlers) {
244+
try {
245+
handler.DynamicInvoke(this, e);
246+
if (e.Cancel)
247+
return;
248+
} catch (Exception ex) {
249+
_log.Value.FormattedError(typeof(ExceptionlessClient), ex, "Error while invoking SubmittedEvent handler: {0}", ex.Message);
250+
}
251+
}
252+
}
253+
228254
void IDisposable.Dispose() {
229255
Configuration.Resolver.Dispose();
230256
}

0 commit comments

Comments
 (0)