-
-
Notifications
You must be signed in to change notification settings - Fork 230
Expand file tree
/
Copy pathMainPage.xaml.cs
More file actions
113 lines (95 loc) · 2.76 KB
/
MainPage.xaml.cs
File metadata and controls
113 lines (95 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
using System.Globalization;
using Microsoft.Extensions.Logging;
namespace Sentry.Samples.Maui;
public partial class MainPage
{
private readonly ILogger<MainPage> _logger;
private int _count = 0;
// NOTE: You can only inject an ILogger<T>, not a plain ILogger
public MainPage(ILogger<MainPage> logger)
{
_logger = logger;
InitializeComponent();
}
protected override void OnAppearing()
{
#if !ANDROID
JavaCrashBtn.IsVisible = false;
#endif
#if !__MOBILE__
NativeCrashBtn.IsVisible = false;
#endif
base.OnAppearing();
}
private void OnCounterClicked(object sender, EventArgs e)
{
_count++;
if (_count == 1)
{
CounterBtn.Text = $"Clicked {_count} time";
}
else
{
CounterBtn.Text = $"Clicked {_count} times";
}
SemanticScreenReader.Announce(CounterBtn.Text);
_logger.LogInformation("The button has been clicked {ClickCount} times", _count);
}
private void OnUnhandledExceptionClicked(object sender, EventArgs e)
{
#pragma warning disable CS0618
SentrySdk.CauseCrash(CrashType.Managed);
#pragma warning restore CS0618
}
private void OnBackgroundThreadUnhandledExceptionClicked(object sender, EventArgs e)
{
#pragma warning disable CS0618
SentrySdk.CauseCrash(CrashType.ManagedBackgroundThread);
#pragma warning restore CS0618
}
private void OnCapturedExceptionClicked(object sender, EventArgs e)
{
try
{
throw new ApplicationException("This exception was thrown and captured manually, without crashing the app.");
}
catch (Exception ex)
{
SentrySdk.CaptureException(ex);
}
}
private void OnJavaCrashClicked(object sender, EventArgs e)
{
#if ANDROID
#pragma warning disable CS0618
SentrySdk.CauseCrash(CrashType.Java);
#pragma warning restore CS0618
#endif
}
private void OnNativeCrashClicked(object sender, EventArgs e)
{
#if __MOBILE__
#pragma warning disable CS0618
SentrySdk.CauseCrash(CrashType.Native);
#pragma warning restore CS0618
#endif
}
private class FlakyMessageHandler : DelegatingHandler
{
protected override Task<HttpResponseMessage> SendAsync(
HttpRequestMessage request,
CancellationToken cancellationToken)
=> throw new Exception();
}
private async void OnFeedbackClicked(object sender, EventArgs e)
{
await Navigation.PushModalAsync(new SubmitFeedback());
}
private void CtMvvmBtn_OnClicked(object sender, EventArgs e)
{
Shell.Current.GoToAsync("ctmvvm");
}
private void TapGestureRecognizer_OnTapped(object sender, TappedEventArgs e)
{
}
}