Skip to content

Commit 5681374

Browse files
committed
Merge pull request #51 from exceptionless/on-submitted-event
#49 OnSubmitted Event Handler
2 parents 2daea2b + a320b07 commit 5681374

8 files changed

+121
-80
lines changed

Exceptionless.Net.sln.DotSettings

Lines changed: 19 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@
8989
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/XmlFormatter/BlankLineAfterProcessingInstructions/@EntryValue">False</s:Boolean>
9090
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/XmlFormatter/MaxBlankLines/@EntryValue">1</s:Int64>
9191
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/XmlFormatter/TagSpaceBeforeHeaderEnd1/@EntryValue">False</s:Boolean>
92-
<s:String x:Key="/Default/CodeStyle/CSharpFileLayoutPatterns/Pattern/@EntryValue">&lt;Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns"&gt;&#xD;
92+
<s:String x:Key="/Default/CodeStyle/CSharpFileLayoutPatterns/Pattern/@EntryValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;&#xD;
93+
&lt;Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns"&gt;&#xD;
9394
&lt;TypePattern DisplayName="COM interfaces or structs"&gt;&#xD;
9495
&lt;TypePattern.Match&gt;&#xD;
9596
&lt;Or&gt;&#xD;
@@ -100,77 +101,67 @@
100101
&lt;HasAttribute Name="System.Runtime.InteropServices.ComImport" /&gt;&#xD;
101102
&lt;/Or&gt;&#xD;
102103
&lt;/And&gt;&#xD;
103-
&lt;HasAttribute Name="System.Runtime.InteropServices.StructLayoutAttribute" /&gt;&#xD;
104+
&lt;Kind Is="Struct" /&gt;&#xD;
104105
&lt;/Or&gt;&#xD;
105106
&lt;/TypePattern.Match&gt;&#xD;
106107
&lt;/TypePattern&gt;&#xD;
107-
&#xD;
108108
&lt;TypePattern DisplayName="NUnit Test Fixtures" RemoveRegions="All"&gt;&#xD;
109109
&lt;TypePattern.Match&gt;&#xD;
110110
&lt;And&gt;&#xD;
111111
&lt;Kind Is="Class" /&gt;&#xD;
112-
&lt;HasAttribute Name="NUnit.Framework.TestFixtureAttribute" Inherited="true" /&gt;&#xD;
113-
&lt;HasAttribute Name="NUnit.Framework.TestCaseFixtureAttribute" Inherited="true" /&gt;&#xD;
112+
&lt;HasAttribute Name="NUnit.Framework.TestFixtureAttribute" Inherited="True" /&gt;&#xD;
113+
&lt;HasAttribute Name="NUnit.Framework.TestCaseFixtureAttribute" Inherited="True" /&gt;&#xD;
114114
&lt;/And&gt;&#xD;
115115
&lt;/TypePattern.Match&gt;&#xD;
116-
&#xD;
117116
&lt;Entry DisplayName="Setup/Teardown Methods"&gt;&#xD;
118117
&lt;Entry.Match&gt;&#xD;
119118
&lt;And&gt;&#xD;
120119
&lt;Kind Is="Method" /&gt;&#xD;
121120
&lt;Or&gt;&#xD;
122-
&lt;HasAttribute Name="NUnit.Framework.SetUpAttribute" Inherited="true" /&gt;&#xD;
123-
&lt;HasAttribute Name="NUnit.Framework.TearDownAttribute" Inherited="true" /&gt;&#xD;
124-
&lt;HasAttribute Name="NUnit.Framework.FixtureSetUpAttribute" Inherited="true" /&gt;&#xD;
125-
&lt;HasAttribute Name="NUnit.Framework.FixtureTearDownAttribute" Inherited="true" /&gt;&#xD;
121+
&lt;HasAttribute Name="NUnit.Framework.SetUpAttribute" Inherited="True" /&gt;&#xD;
122+
&lt;HasAttribute Name="NUnit.Framework.TearDownAttribute" Inherited="True" /&gt;&#xD;
123+
&lt;HasAttribute Name="NUnit.Framework.FixtureSetUpAttribute" Inherited="True" /&gt;&#xD;
124+
&lt;HasAttribute Name="NUnit.Framework.FixtureTearDownAttribute" Inherited="True" /&gt;&#xD;
126125
&lt;/Or&gt;&#xD;
127126
&lt;/And&gt;&#xD;
128127
&lt;/Entry.Match&gt;&#xD;
129128
&lt;/Entry&gt;&#xD;
130-
&#xD;
131129
&lt;Entry DisplayName="All other members" /&gt;&#xD;
132-
&#xD;
133-
&lt;Entry DisplayName="Test Methods" Priority="100"&gt;&#xD;
130+
&lt;Entry Priority="100" DisplayName="Test Methods"&gt;&#xD;
134131
&lt;Entry.Match&gt;&#xD;
135132
&lt;And&gt;&#xD;
136133
&lt;Kind Is="Method" /&gt;&#xD;
137-
&lt;HasAttribute Name="NUnit.Framework.TestAttribute" Inherited="false" /&gt;&#xD;
134+
&lt;HasAttribute Name="NUnit.Framework.TestAttribute" /&gt;&#xD;
138135
&lt;/And&gt;&#xD;
139136
&lt;/Entry.Match&gt;&#xD;
140-
&#xD;
141137
&lt;Entry.SortBy&gt;&#xD;
142138
&lt;Name /&gt;&#xD;
143139
&lt;/Entry.SortBy&gt;&#xD;
144140
&lt;/Entry&gt;&#xD;
145141
&lt;/TypePattern&gt;&#xD;
146-
&#xD;
147142
&lt;TypePattern DisplayName="Default Pattern"&gt;&#xD;
148-
&lt;Entry DisplayName="Public Delegates" Priority="100"&gt;&#xD;
143+
&lt;Entry Priority="100" DisplayName="Public Delegates"&gt;&#xD;
149144
&lt;Entry.Match&gt;&#xD;
150145
&lt;And&gt;&#xD;
151146
&lt;Access Is="Public" /&gt;&#xD;
152147
&lt;Kind Is="Delegate" /&gt;&#xD;
153148
&lt;/And&gt;&#xD;
154149
&lt;/Entry.Match&gt;&#xD;
155-
&#xD;
156150
&lt;Entry.SortBy&gt;&#xD;
157151
&lt;Name /&gt;&#xD;
158152
&lt;/Entry.SortBy&gt;&#xD;
159153
&lt;/Entry&gt;&#xD;
160-
&#xD;
161-
&lt;Entry DisplayName="Public Enums" Priority="100"&gt;&#xD;
154+
&lt;Entry Priority="100" DisplayName="Public Enums"&gt;&#xD;
162155
&lt;Entry.Match&gt;&#xD;
163156
&lt;And&gt;&#xD;
164157
&lt;Access Is="Public" /&gt;&#xD;
165158
&lt;Kind Is="Enum" /&gt;&#xD;
166159
&lt;/And&gt;&#xD;
167160
&lt;/Entry.Match&gt;&#xD;
168-
&#xD;
169161
&lt;Entry.SortBy&gt;&#xD;
170162
&lt;Name /&gt;&#xD;
171163
&lt;/Entry.SortBy&gt;&#xD;
172164
&lt;/Entry&gt;&#xD;
173-
&#xD;
174165
&lt;Entry DisplayName="Static Fields and Constants"&gt;&#xD;
175166
&lt;Entry.Match&gt;&#xD;
176167
&lt;Or&gt;&#xD;
@@ -181,17 +172,10 @@
181172
&lt;/And&gt;&#xD;
182173
&lt;/Or&gt;&#xD;
183174
&lt;/Entry.Match&gt;&#xD;
184-
&#xD;
185175
&lt;Entry.SortBy&gt;&#xD;
186-
&lt;Kind&gt;&#xD;
187-
&lt;Kind.Order&gt;&#xD;
188-
&lt;DeclarationKind&gt;Constant&lt;/DeclarationKind&gt;&#xD;
189-
&lt;DeclarationKind&gt;Field&lt;/DeclarationKind&gt;&#xD;
190-
&lt;/Kind.Order&gt;&#xD;
191-
&lt;/Kind&gt;&#xD;
176+
&lt;Kind Order="Constant Field" /&gt;&#xD;
192177
&lt;/Entry.SortBy&gt;&#xD;
193178
&lt;/Entry&gt;&#xD;
194-
&#xD;
195179
&lt;Entry DisplayName="Fields"&gt;&#xD;
196180
&lt;Entry.Match&gt;&#xD;
197181
&lt;And&gt;&#xD;
@@ -201,23 +185,19 @@
201185
&lt;/Not&gt;&#xD;
202186
&lt;/And&gt;&#xD;
203187
&lt;/Entry.Match&gt;&#xD;
204-
&#xD;
205188
&lt;Entry.SortBy&gt;&#xD;
206189
&lt;Readonly /&gt;&#xD;
207190
&lt;Name /&gt;&#xD;
208191
&lt;/Entry.SortBy&gt;&#xD;
209192
&lt;/Entry&gt;&#xD;
210-
&#xD;
211193
&lt;Entry DisplayName="Constructors"&gt;&#xD;
212194
&lt;Entry.Match&gt;&#xD;
213195
&lt;Kind Is="Constructor" /&gt;&#xD;
214196
&lt;/Entry.Match&gt;&#xD;
215-
&#xD;
216197
&lt;Entry.SortBy&gt;&#xD;
217-
&lt;Static/&gt;&#xD;
198+
&lt;Static /&gt;&#xD;
218199
&lt;/Entry.SortBy&gt;&#xD;
219200
&lt;/Entry&gt;&#xD;
220-
&#xD;
221201
&lt;Entry DisplayName="Properties, Indexers"&gt;&#xD;
222202
&lt;Entry.Match&gt;&#xD;
223203
&lt;Or&gt;&#xD;
@@ -226,30 +206,25 @@
226206
&lt;/Or&gt;&#xD;
227207
&lt;/Entry.Match&gt;&#xD;
228208
&lt;/Entry&gt;&#xD;
229-
&#xD;
230-
&lt;Entry DisplayName="Interface Implementations" Priority="100"&gt;&#xD;
209+
&lt;Entry Priority="100" DisplayName="Interface Implementations"&gt;&#xD;
231210
&lt;Entry.Match&gt;&#xD;
232211
&lt;And&gt;&#xD;
233212
&lt;Kind Is="Member" /&gt;&#xD;
234213
&lt;ImplementsInterface /&gt;&#xD;
235214
&lt;/And&gt;&#xD;
236215
&lt;/Entry.Match&gt;&#xD;
237-
&#xD;
238216
&lt;Entry.SortBy&gt;&#xD;
239-
&lt;ImplementsInterface Immediate="true" /&gt;&#xD;
217+
&lt;ImplementsInterface Immediate="True" /&gt;&#xD;
240218
&lt;/Entry.SortBy&gt;&#xD;
241219
&lt;/Entry&gt;&#xD;
242-
&#xD;
243220
&lt;Entry DisplayName="All other members" /&gt;&#xD;
244-
&#xD;
245221
&lt;Entry DisplayName="Nested Types"&gt;&#xD;
246222
&lt;Entry.Match&gt;&#xD;
247223
&lt;Kind Is="Type" /&gt;&#xD;
248224
&lt;/Entry.Match&gt;&#xD;
249225
&lt;/Entry&gt;&#xD;
250226
&lt;/TypePattern&gt;&#xD;
251-
&lt;/Patterns&gt;&#xD;
252-
</s:String>
227+
&lt;/Patterns&gt;</s:String>
253228
<s:String x:Key="/Default/CodeStyle/CSharpMemberOrderPattern/CustomPattern/@EntryValue">&lt;?xml version="1.0" encoding="utf-8"?&gt;&#xD;
254229
&lt;Patterns xmlns="urn:shemas-jetbrains-com:member-reordering-patterns"&gt;&#xD;
255230
&#xD;
@@ -563,6 +538,7 @@
563538
<s:Boolean x:Key="/Default/Environment/SearchAndNavigation/MergeOccurences/@EntryValue">True</s:Boolean>
564539
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpFileLayoutPatternsUpgrade/@EntryIndexedValue">True</s:Boolean>
565540
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
541+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAlwaysTreatStructAsNotReorderableMigration/@EntryIndexedValue">True</s:Boolean>
566542
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
567543
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean>
568544
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002EJavaScript_002ECodeStyle_002ESettingsUpgrade_002EJsCodeFormatterSettingsUpgrader/@EntryIndexedValue">True</s:Boolean>

Source/Samples/SampleWpf/MainWindow.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
Click="OnGenerateThreadException" />
3838
<MenuItem Header="Handled Thread Exception"
3939
Click="OnHandledThreadException" />
40+
<MenuItem Header="Close After Throwing Exception"
41+
Click="OnGenerateExceptionAndClose" />
4042
<MenuItem Header="Start Flooding Queue" x:Name="FloodQueueMenuItem" Click="OnFloodQueue" />
4143
<Separator />
4244
<MenuItem Header="Import Demo Reports"

Source/Samples/SampleWpf/MainWindow.xaml.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@
55
using System.Threading.Tasks;
66
using System.Windows;
77
using Exceptionless.Models.Collections;
8+
using Exceptionless.Plugins;
89

910
namespace Exceptionless.SampleWpf {
1011
public partial class MainWindow : Window {
12+
private const string FORCE_CLOSE_APPLICATION_KEY = "ForceCloseApplication";
13+
1114
public MainWindow() {
1215
InitializeComponent();
1316

1417
ExceptionlessClient.Default.SubmittingEvent += OnSubmittingEvent;
18+
ExceptionlessClient.Default.SubmittedEvent += OnSubmittedEvent;
1519
ExceptionlessClient.Default.Configuration.Settings.Changed += SettingsOnChanged;
1620
}
17-
21+
1822
private void SettingsOnChanged(object sender, ChangedEventArgs<KeyValuePair<string, string>> args) {
1923
WriteLog("Configuration updated.");
2024
}
@@ -29,6 +33,13 @@ private void OnSubmittingEvent(object sender, EventSubmittingEventArgs e) {
2933
else
3034
WriteLog("Submitting Event");
3135
}
36+
37+
private void OnSubmittedEvent(object sender, EventSubmittedEventArgs e) {
38+
if (e.PluginContextData.ContainsKey(FORCE_CLOSE_APPLICATION_KEY)) {
39+
WriteLog("Shutting down application");
40+
Application.Current.Shutdown();
41+
}
42+
}
3243

3344
private void WriteLog(string message) {
3445
if (logTextBox.Dispatcher.CheckAccess())
@@ -71,6 +82,15 @@ private void OnImportDemoReports(object sender, RoutedEventArgs e) {}
7182
private void OnProcessQueue(object sender, RoutedEventArgs e) {
7283
ExceptionlessClient.Default.ProcessQueueAsync();
7384
}
85+
86+
private void OnGenerateExceptionAndClose(object sender, RoutedEventArgs e) {
87+
try {
88+
throw new Exception("TEST!");
89+
} catch (Exception ex) {
90+
var pluginContextData = new ContextData { { FORCE_CLOSE_APPLICATION_KEY, true } };
91+
ex.ToExceptionless(pluginContextData).Submit();
92+
}
93+
}
7494

7595
private void OnGenerateThreadException(object sender, RoutedEventArgs e) {
7696
var t = new Thread(() => {
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using Exceptionless.Models;
3+
using Exceptionless.Plugins;
4+
5+
namespace Exceptionless {
6+
public abstract class EventSubmissionEventArgsBase : EventArgs {
7+
protected EventSubmissionEventArgsBase(ExceptionlessClient client, Event data, ContextData pluginContextData) {
8+
Client = client;
9+
Event = data;
10+
PluginContextData = pluginContextData;
11+
}
12+
13+
/// <summary>
14+
/// The client instance that is submitting the event.
15+
/// </summary>
16+
public ExceptionlessClient Client { get; private set; }
17+
18+
/// <summary>
19+
/// The event that is being submitted.
20+
/// </summary>
21+
public Event Event { get; private set; }
22+
23+
/// <summary>
24+
/// Any contextual data objects to be used by Exceptionless plugins to gather default
25+
/// information to add to the event data.
26+
/// </summary>
27+
public ContextData PluginContextData { get; private set; }
28+
29+
/// <summary>
30+
/// Wether the event is an unhandled error.
31+
/// </summary>
32+
public bool IsUnhandledError {
33+
get { return PluginContextData != null && PluginContextData.IsUnhandledError; }
34+
}
35+
}
36+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System;
2+
using Exceptionless.Models;
3+
using Exceptionless.Plugins;
4+
5+
namespace Exceptionless {
6+
public class EventSubmittedEventArgs : EventSubmissionEventArgsBase {
7+
public EventSubmittedEventArgs(ExceptionlessClient client, Event data, ContextData pluginContextData) : base(client, data, pluginContextData) {}
8+
}
9+
}

Source/Shared/Events/EventSubmittingEventArgs.cs

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,8 @@
33
using Exceptionless.Models;
44

55
namespace Exceptionless {
6-
public class EventSubmittingEventArgs : EventArgs {
7-
public EventSubmittingEventArgs(ExceptionlessClient client, Event data, ContextData pluginContextData) {
8-
Client = client;
9-
Event = data;
10-
PluginContextData = pluginContextData;
11-
}
12-
13-
/// <summary>
14-
/// The client instance that is submitting the event.
15-
/// </summary>
16-
public ExceptionlessClient Client { get; private set; }
17-
18-
/// <summary>
19-
/// The event that is being submitted.
20-
/// </summary>
21-
public Event Event { get; private set; }
22-
23-
/// <summary>
24-
/// Any contextual data objects to be used by Exceptionless plugins to gather default
25-
/// information to add to the event data.
26-
/// </summary>
27-
public ContextData PluginContextData { get; private set; }
28-
29-
/// <summary>
30-
/// Wether the event is an unhandled error.
31-
/// </summary>
32-
public bool IsUnhandledError {
33-
get { return PluginContextData != null && PluginContextData.IsUnhandledError; }
34-
}
35-
6+
public class EventSubmittingEventArgs : EventSubmissionEventArgsBase {
7+
public EventSubmittingEventArgs(ExceptionlessClient client, Event data, ContextData pluginContextData) : base(client, data, pluginContextData) {}
368
/// <summary>
379
/// Wether the event should be canceled.
3810
/// </summary>

Source/Shared/Exceptionless.Portable.csproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
<RootNamespace>Exceptionless</RootNamespace>
1212
<AssemblyName>Exceptionless.Portable</AssemblyName>
1313
<TargetPortable Condition=" '$(TargetPortable)' == '' ">true</TargetPortable>
14-
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
1515
<FileAlignment>512</FileAlignment>
1616
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\</SolutionDir>
17-
</PropertyGroup>
17+
</PropertyGroup>
1818
<PropertyGroup Condition=" '$(TargetPortable)' == 'true' ">
1919
<TargetFrameworkProfile>Profile328</TargetFrameworkProfile>
2020
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
@@ -57,6 +57,8 @@
5757
<Compile Include="Dependency\DependencyResolverExtensions.cs" />
5858
<Compile Include="Dependency\IDependencyResolver.cs" />
5959
<Compile Include="Dependency\TinyIoC.cs" />
60+
<Compile Include="Events\EventSubmissionEventArgsBase.cs" />
61+
<Compile Include="Events\EventSubmittedEventArgs.cs" />
6062
<Compile Include="Plugins\Default\DuplicateCheckerPlugin.cs" />
6163
<Compile Include="Plugins\ContextData.cs" />
6264
<Compile Include="Plugins\Default\ActionPlugin.cs" />

0 commit comments

Comments
 (0)