Skip to content

Commit 87668f5

Browse files
committed
removing '-event' suffix from event names to normalise naming convention
1 parent ea68802 commit 87668f5

File tree

11 files changed

+53
-63
lines changed

11 files changed

+53
-63
lines changed

src/ElectronNET.API/API/App.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public event Action WindowAllClosed
4141
}
4242
});
4343

44-
BridgeConnector.Socket.Emit("register-app-window-all-closed-event", GetHashCode());
44+
BridgeConnector.Socket.Emit("register-app-window-all-closed", GetHashCode());
4545
}
4646
_windowAllClosed += value;
4747
}
@@ -113,7 +113,7 @@ public event Func<QuitEventArgs, Task> BeforeQuit
113113
}
114114
});
115115

116-
BridgeConnector.Socket.Emit("register-app-before-quit-event", GetHashCode());
116+
BridgeConnector.Socket.Emit("register-app-before-quit", GetHashCode());
117117
}
118118
_beforeQuit += value;
119119
}
@@ -164,7 +164,7 @@ public event Func<QuitEventArgs, Task> WillQuit
164164
}
165165
});
166166

167-
BridgeConnector.Socket.Emit("register-app-will-quit-event", GetHashCode());
167+
BridgeConnector.Socket.Emit("register-app-will-quit", GetHashCode());
168168
}
169169
_willQuit += value;
170170
}
@@ -199,7 +199,7 @@ public event Func<Task> Quitting
199199
}
200200
});
201201

202-
BridgeConnector.Socket.Emit("register-app-will-quit-event", GetHashCode() + "quitting");
202+
BridgeConnector.Socket.Emit("register-app-will-quit", GetHashCode() + "quitting");
203203
}
204204
_quitting += value;
205205
}
@@ -219,7 +219,7 @@ public event Func<Task> Quitting
219219
/// </summary>
220220
public event Action BrowserWindowBlur
221221
{
222-
add => ApiEventManager.AddEventWithSuffix("app-browser-window-blur", GetHashCode(), _browserWindowBlur, value);
222+
add => ApiEventManager.AddEvent("app-browser-window-blur", GetHashCode(), _browserWindowBlur, value);
223223
remove => ApiEventManager.RemoveEvent("app-browser-window-blur", GetHashCode(), _browserWindowBlur, value);
224224
}
225225

@@ -230,7 +230,7 @@ public event Action BrowserWindowBlur
230230
/// </summary>
231231
public event Action BrowserWindowFocus
232232
{
233-
add => ApiEventManager.AddEventWithSuffix("app-browser-window-focus", GetHashCode(), _browserWindowFocus, value);
233+
add => ApiEventManager.AddEvent("app-browser-window-focus", GetHashCode(), _browserWindowFocus, value);
234234
remove => ApiEventManager.RemoveEvent("app-browser-window-focus", GetHashCode(), _browserWindowFocus, value);
235235
}
236236

@@ -241,7 +241,7 @@ public event Action BrowserWindowFocus
241241
/// </summary>
242242
public event Action BrowserWindowCreated
243243
{
244-
add => ApiEventManager.AddEventWithSuffix("app-browser-window-created", GetHashCode(), _browserWindowCreated, value);
244+
add => ApiEventManager.AddEvent("app-browser-window-created", GetHashCode(), _browserWindowCreated, value);
245245
remove => ApiEventManager.RemoveEvent("app-browser-window-created", GetHashCode(), _browserWindowCreated, value);
246246
}
247247

@@ -252,7 +252,7 @@ public event Action BrowserWindowCreated
252252
/// </summary>
253253
public event Action WebContentsCreated
254254
{
255-
add => ApiEventManager.AddEventWithSuffix("app-web-contents-created", GetHashCode(), _webContentsCreated, value);
255+
add => ApiEventManager.AddEvent("app-web-contents-created", GetHashCode(), _webContentsCreated, value);
256256
remove => ApiEventManager.RemoveEvent("app-web-contents-created", GetHashCode(), _webContentsCreated, value);
257257
}
258258

@@ -265,7 +265,7 @@ public event Action WebContentsCreated
265265
/// <returns><see langword="true"/> when Chrome's accessibility support is enabled, <see langword="false"/> otherwise.</returns>
266266
public event Action<bool> AccessibilitySupportChanged
267267
{
268-
add => ApiEventManager.AddEventWithSuffix("app-accessibility-support-changed", GetHashCode(), _accessibilitySupportChanged, value, (args) => (bool)args);
268+
add => ApiEventManager.AddEvent("app-accessibility-support-changed", GetHashCode(), _accessibilitySupportChanged, value, (args) => (bool)args);
269269
remove => ApiEventManager.RemoveEvent("app-accessibility-support-changed", GetHashCode(), _accessibilitySupportChanged, value);
270270
}
271271

@@ -320,7 +320,7 @@ internal set
320320
/// </summary>
321321
public event Action<string> OpenFile
322322
{
323-
add => ApiEventManager.AddEventWithSuffix("app-open-file", GetHashCode(), _openFile, value, (args) => args.ToString());
323+
add => ApiEventManager.AddEvent("app-open-file", GetHashCode(), _openFile, value, (args) => args.ToString());
324324
remove => ApiEventManager.RemoveEvent("app-open-file", GetHashCode(), _openFile, value);
325325
}
326326

@@ -333,7 +333,7 @@ public event Action<string> OpenFile
333333
/// </summary>
334334
public event Action<string> OpenUrl
335335
{
336-
add => ApiEventManager.AddEventWithSuffix("app-open-url", GetHashCode(), _openUrl, value, (args) => args.ToString());
336+
add => ApiEventManager.AddEvent("app-open-url", GetHashCode(), _openUrl, value, (args) => args.ToString());
337337
remove => ApiEventManager.RemoveEvent("app-open-url", GetHashCode(), _openUrl, value);
338338
}
339339

src/ElectronNET.API/API/AutoUpdater.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ public Dictionary<string, string> RequestHeaders
288288
/// </summary>
289289
public event Action<string> OnError
290290
{
291-
add => ApiEventManager.AddEventWithSuffix("autoUpdater-error", GetHashCode(), _error, value, (args) => args.ToString());
291+
add => ApiEventManager.AddEvent("autoUpdater-error", GetHashCode(), _error, value, (args) => args.ToString());
292292
remove => ApiEventManager.RemoveEvent("autoUpdater-error", GetHashCode(), _error, value);
293293
}
294294

@@ -299,7 +299,7 @@ public event Action<string> OnError
299299
/// </summary>
300300
public event Action OnCheckingForUpdate
301301
{
302-
add => ApiEventManager.AddEventWithSuffix("autoUpdater-checking-for-update", GetHashCode(), _checkingForUpdate, value);
302+
add => ApiEventManager.AddEvent("autoUpdater-checking-for-update", GetHashCode(), _checkingForUpdate, value);
303303
remove => ApiEventManager.RemoveEvent("autoUpdater-checking-for-update", GetHashCode(), _checkingForUpdate, value);
304304
}
305305

@@ -311,7 +311,7 @@ public event Action OnCheckingForUpdate
311311
/// </summary>
312312
public event Action<UpdateInfo> OnUpdateAvailable
313313
{
314-
add => ApiEventManager.AddEventWithSuffix("autoUpdater-update-available", GetHashCode(), _updateAvailable, value, (args) => JObject.Parse(args.ToString()).ToObject<UpdateInfo>());
314+
add => ApiEventManager.AddEvent("autoUpdater-update-available", GetHashCode(), _updateAvailable, value, (args) => JObject.Parse(args.ToString()).ToObject<UpdateInfo>());
315315
remove => ApiEventManager.RemoveEvent("autoUpdater-update-available", GetHashCode(), _updateAvailable, value);
316316
}
317317

@@ -322,7 +322,7 @@ public event Action<UpdateInfo> OnUpdateAvailable
322322
/// </summary>
323323
public event Action<UpdateInfo> OnUpdateNotAvailable
324324
{
325-
add => ApiEventManager.AddEventWithSuffix("autoUpdater-update-not-available", GetHashCode(), _updateNotAvailable, value, (args) => JObject.Parse(args.ToString()).ToObject<UpdateInfo>());
325+
add => ApiEventManager.AddEvent("autoUpdater-update-not-available", GetHashCode(), _updateNotAvailable, value, (args) => JObject.Parse(args.ToString()).ToObject<UpdateInfo>());
326326
remove => ApiEventManager.RemoveEvent("autoUpdater-update-not-available", GetHashCode(), _updateNotAvailable, value);
327327
}
328328

@@ -333,7 +333,7 @@ public event Action<UpdateInfo> OnUpdateNotAvailable
333333
/// </summary>
334334
public event Action<ProgressInfo> OnDownloadProgress
335335
{
336-
add => ApiEventManager.AddEventWithSuffix("autoUpdater-download-progress", GetHashCode(), _downloadProgress, value, (args) => JObject.Parse(args.ToString()).ToObject<ProgressInfo>());
336+
add => ApiEventManager.AddEvent("autoUpdater-download-progress", GetHashCode(), _downloadProgress, value, (args) => JObject.Parse(args.ToString()).ToObject<ProgressInfo>());
337337
remove => ApiEventManager.RemoveEvent("autoUpdater-download-progress", GetHashCode(), _downloadProgress, value);
338338
}
339339

@@ -344,7 +344,7 @@ public event Action<ProgressInfo> OnDownloadProgress
344344
/// </summary>
345345
public event Action<UpdateInfo> OnUpdateDownloaded
346346
{
347-
add => ApiEventManager.AddEventWithSuffix("autoUpdater-update-downloaded", GetHashCode(), _updateDownloaded, value, (args) => JObject.Parse(args.ToString()).ToObject<UpdateInfo>());
347+
add => ApiEventManager.AddEvent("autoUpdater-update-downloaded", GetHashCode(), _updateDownloaded, value, (args) => JObject.Parse(args.ToString()).ToObject<UpdateInfo>());
348348
remove => ApiEventManager.RemoveEvent("autoUpdater-update-downloaded", GetHashCode(), _updateDownloaded, value);
349349
}
350350

src/ElectronNET.API/API/WindowManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public bool IsQuitOnWindowAllClosed
5151
get => _isQuitOnWindowAllClosed;
5252
set
5353
{
54-
BridgeConnector.Socket.Emit("quit-app-window-all-closed-event", value);
54+
BridgeConnector.Socket.Emit("quit-app-window-all-closed", value);
5555
_isQuitOnWindowAllClosed = value;
5656
}
5757
}

src/ElectronNET.API/Common/ApiEventManager.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace ElectronNET.Common;
77

8-
internal class ApiEventManager
8+
internal static class ApiEventManager
99
{
1010
internal static void AddEvent(string eventName, object id, Action callback, Action value, string suffix = "")
1111
{
@@ -17,11 +17,6 @@ internal static void AddEvent(string eventName, object id, Action callback, Acti
1717
callback += value;
1818
}
1919

20-
internal static void AddEventWithSuffix(string eventName, object id, Action callback, Action value)
21-
{
22-
AddEvent(eventName, id, callback, value, "-event");
23-
}
24-
2520
internal static void RemoveEvent(string eventName, object id, Action callback, Action value)
2621
{
2722
callback -= value;
@@ -52,11 +47,6 @@ internal static void AddEvent<T>(string eventName, object id, Action<T> callback
5247
callback += value;
5348
}
5449

55-
internal static void AddEventWithSuffix<T>(string eventName, object id, Action<T> callback, Action<T> value, Func<object, T> converter)
56-
{
57-
AddEvent(eventName, id, callback, value, converter, "-event");
58-
}
59-
6050
internal static void RemoveEvent<T>(string eventName, object id, Action<T> callback, Action<T> value)
6151
{
6252
callback -= value;

src/ElectronNET.Host/api/app.js

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ElectronNET.Host/api/app.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,55 +21,55 @@ export = (socket: Socket, app: Electron.App) => {
2121
}
2222
});
2323

24-
socket.on('quit-app-window-all-closed-event', (quit) => {
24+
socket.on('quit-app-window-all-closed', (quit) => {
2525
isQuitWindowAllClosed = quit;
2626
});
2727

28-
socket.on('register-app-window-all-closed-event', (id) => {
28+
socket.on('register-app-window-all-closed', (id) => {
2929
appWindowAllClosedEventId = id;
3030
});
3131

32-
socket.on('register-app-before-quit-event', (id) => {
32+
socket.on('register-app-before-quit', (id) => {
3333
app.on('before-quit', (event) => {
3434
event.preventDefault();
3535

3636
electronSocket.emit('app-before-quit' + id);
3737
});
3838
});
3939

40-
socket.on('register-app-will-quit-event', (id) => {
40+
socket.on('register-app-will-quit', (id) => {
4141
app.on('will-quit', (event) => {
4242
event.preventDefault();
4343

4444
electronSocket.emit('app-will-quit' + id);
4545
});
4646
});
4747

48-
socket.on('register-app-browser-window-blur-event', (id) => {
48+
socket.on('register-app-browser-window-blur', (id) => {
4949
app.on('browser-window-blur', () => {
5050
electronSocket.emit('app-browser-window-blur' + id);
5151
});
5252
});
5353

54-
socket.on('register-app-browser-window-focus-event', (id) => {
54+
socket.on('register-app-browser-window-focus', (id) => {
5555
app.on('browser-window-focus', () => {
5656
electronSocket.emit('app-browser-window-focus' + id);
5757
});
5858
});
5959

60-
socket.on('register-app-browser-window-created-event', (id) => {
60+
socket.on('register-app-browser-window-created', (id) => {
6161
app.on('browser-window-created', () => {
6262
electronSocket.emit('app-browser-window-created' + id);
6363
});
6464
});
6565

66-
socket.on('register-app-web-contents-created-event', (id) => {
66+
socket.on('register-app-web-contents-created', (id) => {
6767
app.on('web-contents-created', () => {
6868
electronSocket.emit('app-web-contents-created' + id);
6969
});
7070
});
7171

72-
socket.on('register-app-accessibility-support-changed-event', (id) => {
72+
socket.on('register-app-accessibility-support-changed', (id) => {
7373
app.on('accessibility-support-changed', (event, accessibilitySupportEnabled) => {
7474
electronSocket.emit('app-accessibility-support-changed' + id, accessibilitySupportEnabled);
7575
});

src/ElectronNET.Host/api/autoUpdater.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ElectronNET.Host/api/autoUpdater.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,37 @@ let electronSocket;
55
export = (socket: Socket) => {
66
electronSocket = socket;
77

8-
socket.on('register-autoUpdater-error-event', (id) => {
8+
socket.on('register-autoUpdater-error', (id) => {
99
autoUpdater.on('error', (error) => {
1010
electronSocket.emit('autoUpdater-error' + id, error.message);
1111
});
1212
});
1313

14-
socket.on('register-autoUpdater-checking-for-update-event', (id) => {
14+
socket.on('register-autoUpdater-checking-for-update', (id) => {
1515
autoUpdater.on('checking-for-update', () => {
1616
electronSocket.emit('autoUpdater-checking-for-update' + id);
1717
});
1818
});
1919

20-
socket.on('register-autoUpdater-update-available-event', (id) => {
20+
socket.on('register-autoUpdater-update-available', (id) => {
2121
autoUpdater.on('update-available', (updateInfo) => {
2222
electronSocket.emit('autoUpdater-update-available' + id, updateInfo);
2323
});
2424
});
2525

26-
socket.on('register-autoUpdater-update-not-available-event', (id) => {
26+
socket.on('register-autoUpdater-update-not-available', (id) => {
2727
autoUpdater.on('update-not-available', (updateInfo) => {
2828
electronSocket.emit('autoUpdater-update-not-available' + id, updateInfo);
2929
});
3030
});
3131

32-
socket.on('register-autoUpdater-download-progress-event', (id) => {
32+
socket.on('register-autoUpdater-download-progress', (id) => {
3333
autoUpdater.on('download-progress', (progressInfo) => {
3434
electronSocket.emit('autoUpdater-download-progress' + id, progressInfo);
3535
});
3636
});
3737

38-
socket.on('register-autoUpdater-update-downloaded-event', (id) => {
38+
socket.on('register-autoUpdater-update-downloaded', (id) => {
3939
autoUpdater.on('update-downloaded', (updateInfo) => {
4040
electronSocket.emit('autoUpdater-update-downloaded' + id, updateInfo);
4141
});

0 commit comments

Comments
 (0)