forked from bUnit-dev/bUnit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgressEventDispatchExtensions.cs
219 lines (198 loc) · 15.4 KB
/
ProgressEventDispatchExtensions.cs
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AngleSharp.Dom;
using Microsoft.AspNetCore.Components.Web;
namespace Egil.RazorComponents.Testing.EventDispatchExtensions
{
/// <summary>
/// Pointer event dispatch helper extension methods.
/// </summary>
public static class ProgressEventDispatchExtensions
{
/// <summary>
/// Raises the <c>@onloadstart</c> event on <paramref name="element"/>, passing the provided
/// properties to the event handler via a <see cref="ProgressEventArgs"/> object.
/// </summary>
/// <param name="element">The element to raise the event on.</param>
/// <param name="lengthComputable">Whether or not the total size of the transfer is known.</param>
/// <param name="loaded">The number of bytes transferred since the beginning of the operation. This doesn't include headers and other overhead, but only the content itself.</param>
/// <param name="total">The total number of bytes of content that will be transferred during the operation. If the total size is unknown, this value is zero.</param>
/// <param name="type">Gets or sets the type of the event.</param>
public static void LoadStart(this IElement element, bool lengthComputable = default, long loaded = default, long total = default, string? type = default)
=> _ = LoadStartAsync(element, new ProgressEventArgs { LengthComputable = lengthComputable, Loaded = loaded, Total = total, Type = type });
/// <summary>
/// Raises the <c>@onloadstart</c> event on <paramref name="element"/>, passing the provided <paramref name="eventArgs"/>
/// to the event handler.
/// </summary>
/// <param name="element">The element to raise the event on.</param>
/// <param name="eventArgs">The event arguments to pass to the event handler.</param>
public static void LoadStart(this IElement element, ProgressEventArgs eventArgs) => _ = LoadStartAsync(element, eventArgs);
/// <summary>
/// Raises the <c>@onloadstart</c> event on <paramref name="element"/>, passing the provided <paramref name="eventArgs"/>
/// to the event handler.
/// </summary>
/// <param name="element"></param>
/// <param name="eventArgs"></param>
/// <returns>A task that completes when the event handler is done.</returns>
public static Task LoadStartAsync(this IElement element, ProgressEventArgs eventArgs) => element.TriggerEventAsync("onloadstart", eventArgs);
/// <summary>
/// Raises the <c>@ontimeout</c> event on <paramref name="element"/>, passing the provided
/// properties to the event handler via a <see cref="ProgressEventArgs"/> object.
/// </summary>
/// <param name="element">The element to raise the event on.</param>
/// <param name="lengthComputable">Whether or not the total size of the transfer is known.</param>
/// <param name="loaded">The number of bytes transferred since the beginning of the operation. This doesn't include headers and other overhead, but only the content itself.</param>
/// <param name="total">The total number of bytes of content that will be transferred during the operation. If the total size is unknown, this value is zero.</param>
/// <param name="type">Gets or sets the type of the event.</param>
public static void Timeout(this IElement element, bool lengthComputable = default, long loaded = default, long total = default, string? type = default)
=> _ = TimeoutAsync(element, new ProgressEventArgs { LengthComputable = lengthComputable, Loaded = loaded, Total = total, Type = type });
/// <summary>
/// Raises the <c>@ontimeout</c> event on <paramref name="element"/>, passing the provided <paramref name="eventArgs"/>
/// to the event handler.
/// </summary>
/// <param name="element">The element to raise the event on.</param>
/// <param name="eventArgs">The event arguments to pass to the event handler.</param>
public static void Timeout(this IElement element, ProgressEventArgs eventArgs) => _ = TimeoutAsync(element, eventArgs);
/// <summary>
/// Raises the <c>@ontimeout</c> event on <paramref name="element"/>, passing the provided <paramref name="eventArgs"/>
/// to the event handler.
/// </summary>
/// <param name="element"></param>
/// <param name="eventArgs"></param>
/// <returns>A task that completes when the event handler is done.</returns>
public static Task TimeoutAsync(this IElement element, ProgressEventArgs eventArgs) => element.TriggerEventAsync("ontimeout", eventArgs);
/// <summary>
/// Raises the <c>@onabort</c> event on <paramref name="element"/>, passing the provided
/// properties to the event handler via a <see cref="ProgressEventArgs"/> object.
/// </summary>
/// <param name="element">The element to raise the event on.</param>
/// <param name="lengthComputable">Whether or not the total size of the transfer is known.</param>
/// <param name="loaded">The number of bytes transferred since the beginning of the operation. This doesn't include headers and other overhead, but only the content itself.</param>
/// <param name="total">The total number of bytes of content that will be transferred during the operation. If the total size is unknown, this value is zero.</param>
/// <param name="type">Gets or sets the type of the event.</param>
public static void Abort(this IElement element, bool lengthComputable = default, long loaded = default, long total = default, string? type = default)
=> _ = AbortAsync(element, new ProgressEventArgs { LengthComputable = lengthComputable, Loaded = loaded, Total = total, Type = type });
/// <summary>
/// Raises the <c>@onabort</c> event on <paramref name="element"/>, passing the provided <paramref name="eventArgs"/>
/// to the event handler.
/// </summary>
/// <param name="element">The element to raise the event on.</param>
/// <param name="eventArgs">The event arguments to pass to the event handler.</param>
public static void Abort(this IElement element, ProgressEventArgs eventArgs) => _ = AbortAsync(element, eventArgs);
/// <summary>
/// Raises the <c>@onabort</c> event on <paramref name="element"/>, passing the provided <paramref name="eventArgs"/>
/// to the event handler.
/// </summary>
/// <param name="element"></param>
/// <param name="eventArgs"></param>
/// <returns>A task that completes when the event handler is done.</returns>
public static Task AbortAsync(this IElement element, ProgressEventArgs eventArgs) => element.TriggerEventAsync("onabort", eventArgs);
/// <summary>
/// Raises the <c>@onload</c> event on <paramref name="element"/>, passing the provided
/// properties to the event handler via a <see cref="ProgressEventArgs"/> object.
/// </summary>
/// <param name="element">The element to raise the event on.</param>
/// <param name="lengthComputable">Whether or not the total size of the transfer is known.</param>
/// <param name="loaded">The number of bytes transferred since the beginning of the operation. This doesn't include headers and other overhead, but only the content itself.</param>
/// <param name="total">The total number of bytes of content that will be transferred during the operation. If the total size is unknown, this value is zero.</param>
/// <param name="type">Gets or sets the type of the event.</param>
public static void Load(this IElement element, bool lengthComputable = default, long loaded = default, long total = default, string? type = default)
=> _ = LoadAsync(element, new ProgressEventArgs { LengthComputable = lengthComputable, Loaded = loaded, Total = total, Type = type });
/// <summary>
/// Raises the <c>@onload</c> event on <paramref name="element"/>, passing the provided <paramref name="eventArgs"/>
/// to the event handler.
/// </summary>
/// <param name="element">The element to raise the event on.</param>
/// <param name="eventArgs">The event arguments to pass to the event handler.</param>
public static void Load(this IElement element, ProgressEventArgs eventArgs) => _ = LoadAsync(element, eventArgs);
/// <summary>
/// Raises the <c>@onload</c> event on <paramref name="element"/>, passing the provided <paramref name="eventArgs"/>
/// to the event handler.
/// </summary>
/// <param name="element"></param>
/// <param name="eventArgs"></param>
/// <returns>A task that completes when the event handler is done.</returns>
public static Task LoadAsync(this IElement element, ProgressEventArgs eventArgs) => element.TriggerEventAsync("onload", eventArgs);
/// <summary>
/// Raises the <c>@onloadend</c> event on <paramref name="element"/>, passing the provided
/// properties to the event handler via a <see cref="ProgressEventArgs"/> object.
/// </summary>
/// <param name="element">The element to raise the event on.</param>
/// <param name="lengthComputable">Whether or not the total size of the transfer is known.</param>
/// <param name="loaded">The number of bytes transferred since the beginning of the operation. This doesn't include headers and other overhead, but only the content itself.</param>
/// <param name="total">The total number of bytes of content that will be transferred during the operation. If the total size is unknown, this value is zero.</param>
/// <param name="type">Gets or sets the type of the event.</param>
public static void LoadEnd(this IElement element, bool lengthComputable = default, long loaded = default, long total = default, string? type = default)
=> _ = LoadEndAsync(element, new ProgressEventArgs { LengthComputable = lengthComputable, Loaded = loaded, Total = total, Type = type });
/// <summary>
/// Raises the <c>@onloadend</c> event on <paramref name="element"/>, passing the provided <paramref name="eventArgs"/>
/// to the event handler.
/// </summary>
/// <param name="element">The element to raise the event on.</param>
/// <param name="eventArgs">The event arguments to pass to the event handler.</param>
public static void LoadEnd(this IElement element, ProgressEventArgs eventArgs) => _ = LoadEndAsync(element, eventArgs);
/// <summary>
/// Raises the <c>@onloadend</c> event on <paramref name="element"/>, passing the provided <paramref name="eventArgs"/>
/// to the event handler.
/// </summary>
/// <param name="element"></param>
/// <param name="eventArgs"></param>
/// <returns>A task that completes when the event handler is done.</returns>
public static Task LoadEndAsync(this IElement element, ProgressEventArgs eventArgs) => element.TriggerEventAsync("onloadend", eventArgs);
/// <summary>
/// Raises the <c>@onprogress</c> event on <paramref name="element"/>, passing the provided
/// properties to the event handler via a <see cref="ProgressEventArgs"/> object.
/// </summary>
/// <param name="element">The element to raise the event on.</param>
/// <param name="lengthComputable">Whether or not the total size of the transfer is known.</param>
/// <param name="loaded">The number of bytes transferred since the beginning of the operation. This doesn't include headers and other overhead, but only the content itself.</param>
/// <param name="total">The total number of bytes of content that will be transferred during the operation. If the total size is unknown, this value is zero.</param>
/// <param name="type">Gets or sets the type of the event.</param>
public static void Progress(this IElement element, bool lengthComputable = default, long loaded = default, long total = default, string? type = default)
=> _ = ProgressAsync(element, new ProgressEventArgs { LengthComputable = lengthComputable, Loaded = loaded, Total = total, Type = type });
/// <summary>
/// Raises the <c>@onprogress</c> event on <paramref name="element"/>, passing the provided <paramref name="eventArgs"/>
/// to the event handler.
/// </summary>
/// <param name="element">The element to raise the event on.</param>
/// <param name="eventArgs">The event arguments to pass to the event handler.</param>
public static void Progress(this IElement element, ProgressEventArgs eventArgs) => _ = ProgressAsync(element, eventArgs);
/// <summary>
/// Raises the <c>@onprogress</c> event on <paramref name="element"/>, passing the provided <paramref name="eventArgs"/>
/// to the event handler.
/// </summary>
/// <param name="element"></param>
/// <param name="eventArgs"></param>
/// <returns>A task that completes when the event handler is done.</returns>
public static Task ProgressAsync(this IElement element, ProgressEventArgs eventArgs) => element.TriggerEventAsync("onprogress", eventArgs);
/// <summary>
/// Raises the <c>@onerror</c> event on <paramref name="element"/>, passing the provided
/// properties to the event handler via a <see cref="ProgressEventArgs"/> object.
/// </summary>
/// <param name="element">The element to raise the event on.</param>
/// <param name="lengthComputable">Whether or not the total size of the transfer is known.</param>
/// <param name="loaded">The number of bytes transferred since the beginning of the operation. This doesn't include headers and other overhead, but only the content itself.</param>
/// <param name="total">The total number of bytes of content that will be transferred during the operation. If the total size is unknown, this value is zero.</param>
/// <param name="type">Gets or sets the type of the event.</param>
public static void Error(this IElement element, bool lengthComputable = default, long loaded = default, long total = default, string? type = default)
=> _ = ErrorAsync(element, new ProgressEventArgs { LengthComputable = lengthComputable, Loaded = loaded, Total = total, Type = type });
/// <summary>
/// Raises the <c>@onerror</c> event on <paramref name="element"/>, passing the provided <paramref name="eventArgs"/>
/// to the event handler.
/// </summary>
/// <param name="element">The element to raise the event on.</param>
/// <param name="eventArgs">The event arguments to pass to the event handler.</param>
public static void Error(this IElement element, ProgressEventArgs eventArgs) => _ = ErrorAsync(element, eventArgs);
/// <summary>
/// Raises the <c>@onerror</c> event on <paramref name="element"/>, passing the provided <paramref name="eventArgs"/>
/// to the event handler.
/// </summary>
/// <param name="element"></param>
/// <param name="eventArgs"></param>
/// <returns>A task that completes when the event handler is done.</returns>
public static Task ErrorAsync(this IElement element, ProgressEventArgs eventArgs) => element.TriggerEventAsync("onerror", eventArgs);
}
}