mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-12 21:25:06 +00:00
refactor: Migrated from Newtonsoft.Json to System.Text.Json, missing one test passing
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
using ElectronNET.Common;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using ElectronNET.Common;
|
||||
|
||||
public abstract class ApiBase
|
||||
{
|
||||
@@ -150,14 +151,25 @@
|
||||
|
||||
var messageName = apiBase.propertyMessageNames.GetOrAdd(callerName, s => apiBase.objectName + s.StripAsync());
|
||||
|
||||
BridgeConnector.Socket.On<T>(eventName, (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>(eventName, (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off(eventName);
|
||||
|
||||
lock (this)
|
||||
{
|
||||
this.tcs?.SetResult(result);
|
||||
this.tcs = null;
|
||||
try
|
||||
{
|
||||
var value = JsonSerializer.Deserialize<T>(result, Serialization.ElectronJson.Options);
|
||||
this.tcs?.SetResult(value);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.tcs?.TrySetException(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.tcs = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -170,7 +182,7 @@
|
||||
BridgeConnector.Socket.Emit(messageName);
|
||||
}
|
||||
|
||||
System.Threading.Tasks.Task.Delay(ApiBase.PropertyTimeout).ContinueWith(_ =>
|
||||
System.Threading.Tasks.Task.Delay(PropertyTimeout).ContinueWith(_ =>
|
||||
{
|
||||
if (this.tcs != null)
|
||||
{
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
using ElectronNET.API.Entities;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using ElectronNET.API.Entities;
|
||||
using ElectronNET.API.Extensions;
|
||||
using ElectronNET.Common;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
@@ -271,7 +269,7 @@ namespace ElectronNET.API
|
||||
/// <returns><see langword="true"/> when Chrome's accessibility support is enabled, <see langword="false"/> otherwise.</returns>
|
||||
public event Action<bool> AccessibilitySupportChanged
|
||||
{
|
||||
add => ApiEventManager.AddEvent("app-accessibility-support-changed", GetHashCode(), _accessibilitySupportChanged, value, (args) => (bool)args);
|
||||
add => ApiEventManager.AddEvent("app-accessibility-support-changed", GetHashCode(), _accessibilitySupportChanged, value, (args) => args.GetBoolean());
|
||||
remove => ApiEventManager.RemoveEvent("app-accessibility-support-changed", GetHashCode(), _accessibilitySupportChanged, value);
|
||||
}
|
||||
|
||||
@@ -414,10 +412,7 @@ namespace ElectronNET.API
|
||||
private static App _app;
|
||||
private static object _syncRoot = new object();
|
||||
|
||||
private readonly JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver()
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Try to close all windows. The <see cref="BeforeQuit"/> event will be emitted first. If all windows are successfully
|
||||
@@ -475,7 +470,7 @@ namespace ElectronNET.API
|
||||
/// <param name="relaunchOptions">Options for the relaunch.</param>
|
||||
public void Relaunch(RelaunchOptions relaunchOptions)
|
||||
{
|
||||
this.CallMethod1(JObject.FromObject(relaunchOptions, _jsonSerializer));
|
||||
this.CallMethod1(relaunchOptions);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -495,7 +490,7 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
public void Focus(FocusOptions focusOptions)
|
||||
{
|
||||
this.CallMethod1(JObject.FromObject(focusOptions, _jsonSerializer));
|
||||
this.CallMethod1(focusOptions);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -551,11 +546,11 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.Socket.On("appGetPathCompleted", (path) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("appGetPathCompleted", (path) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("appGetPathCompleted");
|
||||
|
||||
taskCompletionSource.SetResult(path.ToString());
|
||||
taskCompletionSource.SetResult(path.GetString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("appGetPath", pathName.GetDescription());
|
||||
@@ -720,10 +715,10 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.Socket.On("appSetAsDefaultProtocolClientCompleted", (success) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("appSetAsDefaultProtocolClientCompleted", (success) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("appSetAsDefaultProtocolClientCompleted");
|
||||
taskCompletionSource.SetResult((bool)success);
|
||||
taskCompletionSource.SetResult(success.GetBoolean());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("appSetAsDefaultProtocolClient", protocol, path, args);
|
||||
@@ -774,10 +769,10 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.Socket.On("appRemoveAsDefaultProtocolClientCompleted", (success) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("appRemoveAsDefaultProtocolClientCompleted", (success) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("appRemoveAsDefaultProtocolClientCompleted");
|
||||
taskCompletionSource.SetResult((bool)success);
|
||||
taskCompletionSource.SetResult(success.GetBoolean());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("appRemoveAsDefaultProtocolClient", protocol, path, args);
|
||||
@@ -846,10 +841,10 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.Socket.On("appIsDefaultProtocolClientCompleted", (success) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("appIsDefaultProtocolClientCompleted", (success) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("appIsDefaultProtocolClientCompleted");
|
||||
taskCompletionSource.SetResult((bool)success);
|
||||
taskCompletionSource.SetResult(success.GetBoolean());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("appIsDefaultProtocolClient", protocol, path, args);
|
||||
@@ -874,13 +869,13 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.Socket.On("appSetUserTasksCompleted", (success) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("appSetUserTasksCompleted", (success) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("appSetUserTasksCompleted");
|
||||
taskCompletionSource.SetResult((bool)success);
|
||||
taskCompletionSource.SetResult(success.GetBoolean());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("appSetUserTasks", JArray.FromObject(userTasks, _jsonSerializer));
|
||||
BridgeConnector.Socket.Emit("appSetUserTasks", userTasks);
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
.ConfigureAwait(false);
|
||||
@@ -916,7 +911,7 @@ namespace ElectronNET.API
|
||||
/// <param name="categories">Array of <see cref="JumpListCategory"/> objects.</param>
|
||||
public void SetJumpList(JumpListCategory[] categories)
|
||||
{
|
||||
this.CallMethod1(JArray.FromObject(categories, _jsonSerializer));
|
||||
this.CallMethod1(categories);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -947,19 +942,21 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.Socket.On("appRequestSingleInstanceLockCompleted", (success) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("appRequestSingleInstanceLockCompleted", (success) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("appRequestSingleInstanceLockCompleted");
|
||||
taskCompletionSource.SetResult((bool)success);
|
||||
taskCompletionSource.SetResult(success.GetBoolean());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Off("secondInstance");
|
||||
BridgeConnector.Socket.On("secondInstance", (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("secondInstance", (result) =>
|
||||
{
|
||||
JArray results = (JArray)result;
|
||||
string[] args = results.First.ToObject<string[]>();
|
||||
string workingDirectory = results.Last.ToObject<string>();
|
||||
|
||||
var arr = result.EnumerateArray();
|
||||
var e = arr.GetEnumerator();
|
||||
e.MoveNext();
|
||||
var args = e.Current.Deserialize<string[]>(JsonSerializerOptions.Default);
|
||||
e.MoveNext();
|
||||
var workingDirectory = e.Current.GetString();
|
||||
newInstanceOpened(args, workingDirectory);
|
||||
});
|
||||
|
||||
@@ -1071,13 +1068,13 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<int>();
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.Socket.On("appImportCertificateCompleted", (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("appImportCertificateCompleted", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("appImportCertificateCompleted");
|
||||
taskCompletionSource.SetResult((int)result);
|
||||
taskCompletionSource.SetResult(result.GetInt32());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("appImportCertificate", JObject.FromObject(options, _jsonSerializer));
|
||||
BridgeConnector.Socket.Emit("appImportCertificate", options);
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
.ConfigureAwait(false);
|
||||
@@ -1127,10 +1124,10 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.Socket.On("appSetBadgeCountCompleted", (success) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("appSetBadgeCountCompleted", (success) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("appSetBadgeCountCompleted");
|
||||
taskCompletionSource.SetResult((bool)success);
|
||||
taskCompletionSource.SetResult(success.GetBoolean());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("appSetBadgeCount", count);
|
||||
@@ -1187,11 +1184,11 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<LoginItemSettings>();
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.Socket.On("appGetLoginItemSettingsCompleted", (loginItemSettings) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("appGetLoginItemSettingsCompleted", (loginItemSettings) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("appGetLoginItemSettingsCompleted");
|
||||
|
||||
var result = ((JObject)loginItemSettings).ToObject<LoginItemSettings>();
|
||||
var result = JsonSerializer.Deserialize<LoginItemSettings>(loginItemSettings, Serialization.ElectronJson.Options);
|
||||
|
||||
taskCompletionSource.SetResult(result);
|
||||
});
|
||||
@@ -1202,7 +1199,7 @@ namespace ElectronNET.API
|
||||
}
|
||||
else
|
||||
{
|
||||
BridgeConnector.Socket.Emit("appGetLoginItemSettings", JObject.FromObject(options, _jsonSerializer));
|
||||
BridgeConnector.Socket.Emit("appGetLoginItemSettings", options);
|
||||
}
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
@@ -1218,7 +1215,7 @@ namespace ElectronNET.API
|
||||
/// <param name="loginSettings"></param>
|
||||
public void SetLoginItemSettings(LoginSettings loginSettings)
|
||||
{
|
||||
this.CallMethod1(JObject.FromObject(loginSettings, _jsonSerializer));
|
||||
this.CallMethod1(loginSettings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1270,7 +1267,7 @@ namespace ElectronNET.API
|
||||
/// <param name="options">About panel options.</param>
|
||||
public void SetAboutPanelOptions(AboutPanelOptions options)
|
||||
{
|
||||
this.CallMethod1(JObject.FromObject(options, _jsonSerializer));
|
||||
this.CallMethod1(options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1306,14 +1303,14 @@ namespace ElectronNET.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<string>(() =>
|
||||
return Task.Run(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
BridgeConnector.Socket.On("appGetUserAgentFallbackCompleted", (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("appGetUserAgentFallbackCompleted", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("appGetUserAgentFallbackCompleted");
|
||||
taskCompletionSource.SetResult((string)result);
|
||||
taskCompletionSource.SetResult(result.GetString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("appGetUserAgentFallback");
|
||||
@@ -1364,4 +1361,4 @@ namespace ElectronNET.API
|
||||
public async Task Once(string eventName, Action<object> action)
|
||||
=> await Events.Instance.Once(ModuleName, eventName, action).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
using ElectronNET.API.Entities;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using ElectronNET.API.Entities;
|
||||
using ElectronNET.API.Serialization;
|
||||
using ElectronNET.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using ElectronNET.Common;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
@@ -23,14 +22,14 @@ namespace ElectronNET.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<bool>(() =>
|
||||
return Task.Run(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdater-autoDownload-get-reply", (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("autoUpdater-autoDownload-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdater-autoDownload-get-reply");
|
||||
taskCompletionSource.SetResult((bool)result);
|
||||
taskCompletionSource.SetResult(result.GetBoolean());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdater-autoDownload-get");
|
||||
@@ -53,14 +52,14 @@ namespace ElectronNET.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<bool>(() =>
|
||||
return Task.Run(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdater-autoInstallOnAppQuit-get-reply", (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("autoUpdater-autoInstallOnAppQuit-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdater-autoInstallOnAppQuit-get-reply");
|
||||
taskCompletionSource.SetResult((bool)result);
|
||||
taskCompletionSource.SetResult(result.GetBoolean());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdater-autoInstallOnAppQuit-get");
|
||||
@@ -84,14 +83,14 @@ namespace ElectronNET.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<bool>(() =>
|
||||
return Task.Run(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdater-allowPrerelease-get-reply", (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("autoUpdater-allowPrerelease-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdater-allowPrerelease-get-reply");
|
||||
taskCompletionSource.SetResult((bool)result);
|
||||
taskCompletionSource.SetResult(result.GetBoolean());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdater-allowPrerelease-get");
|
||||
@@ -113,14 +112,14 @@ namespace ElectronNET.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<bool>(() =>
|
||||
return Task.Run(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdater-fullChangelog-get-reply", (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("autoUpdater-fullChangelog-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdater-fullChangelog-get-reply");
|
||||
taskCompletionSource.SetResult((bool)result);
|
||||
taskCompletionSource.SetResult(result.GetBoolean());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdater-fullChangelog-get");
|
||||
@@ -143,14 +142,14 @@ namespace ElectronNET.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<bool>(() =>
|
||||
return Task.Run(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdater-allowDowngrade-get-reply", (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("autoUpdater-allowDowngrade-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdater-allowDowngrade-get-reply");
|
||||
taskCompletionSource.SetResult((bool)result);
|
||||
taskCompletionSource.SetResult(result.GetBoolean());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdater-allowDowngrade-get");
|
||||
@@ -171,14 +170,14 @@ namespace ElectronNET.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<string>(() =>
|
||||
return Task.Run(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdater-updateConfigPath-get-reply", (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("autoUpdater-updateConfigPath-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdater-updateConfigPath-get-reply");
|
||||
taskCompletionSource.SetResult(result.ToString());
|
||||
taskCompletionSource.SetResult(result.GetString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdater-updateConfigPath-get");
|
||||
@@ -195,14 +194,14 @@ namespace ElectronNET.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<SemVer>(() =>
|
||||
return Task.Run(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<SemVer>();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdater-currentVersion-get-reply", (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("autoUpdater-currentVersion-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdater-currentVersion-get-reply");
|
||||
SemVer version = ((JObject)result).ToObject<SemVer>();
|
||||
var version = result.Deserialize(ElectronJsonContext.Default.SemVer);
|
||||
taskCompletionSource.SetResult(version);
|
||||
});
|
||||
BridgeConnector.Socket.Emit("autoUpdater-currentVersion-get");
|
||||
@@ -233,14 +232,14 @@ namespace ElectronNET.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<string>(() =>
|
||||
return Task.Run(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdater-channel-get-reply", (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("autoUpdater-channel-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdater-channel-get-reply");
|
||||
taskCompletionSource.SetResult(result.ToString());
|
||||
taskCompletionSource.SetResult(result.GetString());
|
||||
});
|
||||
BridgeConnector.Socket.Emit("autoUpdater-channel-get");
|
||||
|
||||
@@ -260,10 +259,10 @@ namespace ElectronNET.API
|
||||
return Task.Run(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<Dictionary<string, string>>();
|
||||
BridgeConnector.Socket.On("autoUpdater-requestHeaders-get-reply", (headers) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("autoUpdater-requestHeaders-get-reply", (headers) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdater-requestHeaders-get-reply");
|
||||
Dictionary<string, string> result = ((JObject)headers).ToObject<Dictionary<string, string>>();
|
||||
var result = headers.Deserialize<Dictionary<string, string>>(ElectronJson.Options);
|
||||
taskCompletionSource.SetResult(result);
|
||||
});
|
||||
BridgeConnector.Socket.Emit("autoUpdater-requestHeaders-get");
|
||||
@@ -279,7 +278,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
set
|
||||
{
|
||||
BridgeConnector.Socket.Emit("autoUpdater-requestHeaders-set", JObject.FromObject(value, _jsonSerializer));
|
||||
BridgeConnector.Socket.Emit("autoUpdater-requestHeaders-set", value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,7 +310,7 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
public event Action<UpdateInfo> OnUpdateAvailable
|
||||
{
|
||||
add => ApiEventManager.AddEvent("autoUpdater-update-available", GetHashCode(), _updateAvailable, value, (args) => JObject.Parse(args.ToString()).ToObject<UpdateInfo>());
|
||||
add => ApiEventManager.AddEvent("autoUpdater-update-available", GetHashCode(), _updateAvailable, value, (args) => JsonSerializer.Deserialize(args, ElectronJsonContext.Default.UpdateInfo));
|
||||
remove => ApiEventManager.RemoveEvent("autoUpdater-update-available", GetHashCode(), _updateAvailable, value);
|
||||
}
|
||||
|
||||
@@ -322,7 +321,7 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
public event Action<UpdateInfo> OnUpdateNotAvailable
|
||||
{
|
||||
add => ApiEventManager.AddEvent("autoUpdater-update-not-available", GetHashCode(), _updateNotAvailable, value, (args) => JObject.Parse(args.ToString()).ToObject<UpdateInfo>());
|
||||
add => ApiEventManager.AddEvent("autoUpdater-update-not-available", GetHashCode(), _updateNotAvailable, value, (args) => JsonSerializer.Deserialize(args, ElectronJsonContext.Default.UpdateInfo));
|
||||
remove => ApiEventManager.RemoveEvent("autoUpdater-update-not-available", GetHashCode(), _updateNotAvailable, value);
|
||||
}
|
||||
|
||||
@@ -333,7 +332,7 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
public event Action<ProgressInfo> OnDownloadProgress
|
||||
{
|
||||
add => ApiEventManager.AddEvent("autoUpdater-download-progress", GetHashCode(), _downloadProgress, value, (args) => JObject.Parse(args.ToString()).ToObject<ProgressInfo>());
|
||||
add => ApiEventManager.AddEvent("autoUpdater-download-progress", GetHashCode(), _downloadProgress, value, (args) => JsonSerializer.Deserialize(args, ElectronJsonContext.Default.ProgressInfo));
|
||||
remove => ApiEventManager.RemoveEvent("autoUpdater-download-progress", GetHashCode(), _downloadProgress, value);
|
||||
}
|
||||
|
||||
@@ -344,7 +343,7 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
public event Action<UpdateInfo> OnUpdateDownloaded
|
||||
{
|
||||
add => ApiEventManager.AddEvent("autoUpdater-update-downloaded", GetHashCode(), _updateDownloaded, value, (args) => JObject.Parse(args.ToString()).ToObject<UpdateInfo>());
|
||||
add => ApiEventManager.AddEvent("autoUpdater-update-downloaded", GetHashCode(), _updateDownloaded, value, (args) => JsonSerializer.Deserialize(args, ElectronJsonContext.Default.UpdateInfo));
|
||||
remove => ApiEventManager.RemoveEvent("autoUpdater-update-downloaded", GetHashCode(), _updateDownloaded, value);
|
||||
}
|
||||
|
||||
@@ -385,26 +384,26 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<UpdateCheckResult>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesComplete" + guid, (updateCheckResult) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("autoUpdaterCheckForUpdatesComplete" + guid, (updateCheckResult) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesComplete" + guid);
|
||||
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesError" + guid);
|
||||
taskCompletionSource.SetResult(JObject.Parse(updateCheckResult.ToString()).ToObject<UpdateCheckResult>());
|
||||
taskCompletionSource.SetResult(updateCheckResult.Deserialize(ElectronJsonContext.Default.UpdateCheckResult));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
taskCompletionSource.SetException(ex);
|
||||
}
|
||||
});
|
||||
BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesError" + guid, (error) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("autoUpdaterCheckForUpdatesError" + guid, (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesComplete" + guid);
|
||||
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesError" + guid);
|
||||
string message = "An error occurred in CheckForUpdatesAsync";
|
||||
if (error != null && !string.IsNullOrEmpty(error.ToString()))
|
||||
message = JsonConvert.SerializeObject(error);
|
||||
var error = result.GetString();
|
||||
if (!string.IsNullOrEmpty(error)) message = error;
|
||||
taskCompletionSource.SetException(new Exception(message));
|
||||
});
|
||||
|
||||
@@ -424,29 +423,26 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<UpdateCheckResult>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesAndNotifyComplete" + guid, (updateCheckResult) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("autoUpdaterCheckForUpdatesAndNotifyComplete" + guid, (updateCheckResult) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesAndNotifyComplete" + guid);
|
||||
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesAndNotifyError" + guid);
|
||||
if (updateCheckResult == null)
|
||||
taskCompletionSource.SetResult(null);
|
||||
else
|
||||
taskCompletionSource.SetResult(JObject.Parse(updateCheckResult.ToString()).ToObject<UpdateCheckResult>());
|
||||
taskCompletionSource.SetResult(updateCheckResult.Deserialize(ElectronJsonContext.Default.UpdateCheckResult));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
taskCompletionSource.SetException(ex);
|
||||
}
|
||||
});
|
||||
BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesAndNotifyError" + guid, (error) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("autoUpdaterCheckForUpdatesAndNotifyError" + guid, (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesAndNotifyComplete" + guid);
|
||||
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesAndNotifyError" + guid);
|
||||
string message = "An error occurred in autoUpdaterCheckForUpdatesAndNotify";
|
||||
if (error != null)
|
||||
message = JsonConvert.SerializeObject(error);
|
||||
var error = result.GetString();
|
||||
if (!string.IsNullOrEmpty(error)) message = error;
|
||||
taskCompletionSource.SetException(new Exception(message));
|
||||
});
|
||||
|
||||
@@ -478,10 +474,10 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdaterDownloadUpdateComplete" + guid, (downloadedPath) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("autoUpdaterDownloadUpdateComplete" + guid, (downloadedPath) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdaterDownloadUpdateComplete" + guid);
|
||||
taskCompletionSource.SetResult(downloadedPath.ToString());
|
||||
taskCompletionSource.SetResult(downloadedPath.GetString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdaterDownloadUpdate", guid);
|
||||
@@ -498,10 +494,10 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdaterGetFeedURLComplete" + guid, (downloadedPath) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("autoUpdaterGetFeedURLComplete" + guid, (downloadedPath) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdaterGetFeedURLComplete" + guid);
|
||||
taskCompletionSource.SetResult(downloadedPath.ToString());
|
||||
taskCompletionSource.SetResult(downloadedPath.GetString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdaterGetFeedURL", guid);
|
||||
@@ -509,9 +505,8 @@ namespace ElectronNET.API
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
private readonly JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver()
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
using ElectronNET.API.Entities;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using ElectronNET.API.Entities;
|
||||
using ElectronNET.API.Serialization;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
/// <summary>
|
||||
/// A BrowserView can be used to embed additional web content into a BrowserWindow.
|
||||
/// It is like a child window, except that it is positioned relative to its owning window.
|
||||
/// A BrowserView can be used to embed additional web content into a BrowserWindow.
|
||||
/// It is like a child window, except that it is positioned relative to its owning window.
|
||||
/// It is meant to be an alternative to the webview tag.
|
||||
/// </summary>
|
||||
public class BrowserView
|
||||
@@ -16,9 +15,6 @@ namespace ElectronNET.API
|
||||
/// <summary>
|
||||
/// Gets the identifier.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The identifier.
|
||||
/// </value>
|
||||
public int Id { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -28,7 +24,6 @@ namespace ElectronNET.API
|
||||
|
||||
/// <summary>
|
||||
/// Resizes and moves the view to the supplied bounds relative to the window.
|
||||
///
|
||||
/// (experimental)
|
||||
/// </summary>
|
||||
public Rectangle Bounds
|
||||
@@ -39,10 +34,10 @@ namespace ElectronNET.API
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
BridgeConnector.Socket.On<Rectangle>("browserView-getBounds-reply", (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("browserView-getBounds-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserView-getBounds-reply");
|
||||
taskCompletionSource.SetResult(result);
|
||||
taskCompletionSource.SetResult(result.Deserialize(ElectronJsonContext.Default.Rectangle));
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("browserView-getBounds", Id);
|
||||
@@ -52,7 +47,7 @@ namespace ElectronNET.API
|
||||
}
|
||||
set
|
||||
{
|
||||
BridgeConnector.Socket.Emit("browserView-setBounds", Id, JObject.FromObject(value, _jsonSerializer));
|
||||
BridgeConnector.Socket.Emit("browserView-setBounds", Id, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,12 +69,11 @@ namespace ElectronNET.API
|
||||
/// <param name="options"></param>
|
||||
public void SetAutoResize(AutoResizeOptions options)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("browserView-setAutoResize", Id, JObject.FromObject(options, _jsonSerializer));
|
||||
BridgeConnector.Socket.Emit("browserView-setAutoResize", Id, options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Color in #aarrggbb or #argb form. The alpha channel is optional.
|
||||
///
|
||||
/// (experimental)
|
||||
/// </summary>
|
||||
/// <param name="color">Color in #aarrggbb or #argb form. The alpha channel is optional.</param>
|
||||
@@ -87,11 +81,6 @@ namespace ElectronNET.API
|
||||
{
|
||||
BridgeConnector.Socket.Emit("browserView-setBackgroundColor", Id, color);
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,23 +1,17 @@
|
||||
using ElectronNET.API.Entities;
|
||||
using ElectronNET.API.Entities;
|
||||
using ElectronNET.API.Extensions;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using ElectronNET.Common;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace ElectronNET.API;
|
||||
|
||||
using System.Collections.Concurrent;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ElectronNET.Common;
|
||||
using System.Text.Json;
|
||||
|
||||
/// <summary>
|
||||
/// Create and control browser windows.
|
||||
@@ -469,7 +463,7 @@ public class BrowserWindow : ApiBase
|
||||
/// <param name="aspectRatio">The aspect ratio to maintain for some portion of the content view.</param>
|
||||
/// <param name="extraSize">The extra size not to be included while maintaining the aspect ratio.</param>
|
||||
public void SetAspectRatio(double aspectRatio, Size extraSize) =>
|
||||
this.CallMethod2(aspectRatio, JObject.FromObject(extraSize, _jsonSerializer));
|
||||
this.CallMethod2(aspectRatio, extraSize);
|
||||
|
||||
/// <summary>
|
||||
/// This will make a window maintain an aspect ratio. The extra size allows a developer to have space,
|
||||
@@ -486,7 +480,7 @@ public class BrowserWindow : ApiBase
|
||||
/// <param name="aspectRatio">The aspect ratio to maintain for some portion of the content view.</param>
|
||||
/// <param name="extraSize">The extra size not to be included while maintaining the aspect ratio.</param>
|
||||
public void SetAspectRatio(int aspectRatio, Size extraSize) =>
|
||||
this.CallMethod2(aspectRatio, JObject.FromObject(extraSize, _jsonSerializer));
|
||||
this.CallMethod2(aspectRatio, extraSize);
|
||||
|
||||
/// <summary>
|
||||
/// Uses Quick Look to preview a file at a given path.
|
||||
@@ -515,14 +509,14 @@ public class BrowserWindow : ApiBase
|
||||
/// Resizes and moves the window to the supplied bounds
|
||||
/// </summary>
|
||||
/// <param name="bounds"></param>
|
||||
public void SetBounds(Rectangle bounds) => this.CallMethod1(JObject.FromObject(bounds, _jsonSerializer));
|
||||
public void SetBounds(Rectangle bounds) => this.CallMethod1(bounds);
|
||||
|
||||
/// <summary>
|
||||
/// Resizes and moves the window to the supplied bounds
|
||||
/// </summary>
|
||||
/// <param name="bounds"></param>
|
||||
/// <param name="animate"></param>
|
||||
public void SetBounds(Rectangle bounds, bool animate) => this.CallMethod2(JObject.FromObject(bounds, _jsonSerializer), animate);
|
||||
public void SetBounds(Rectangle bounds, bool animate) => this.CallMethod2(bounds, animate);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the bounds asynchronous.
|
||||
@@ -534,14 +528,14 @@ public class BrowserWindow : ApiBase
|
||||
/// Resizes and moves the window’s client area (e.g. the web page) to the supplied bounds.
|
||||
/// </summary>
|
||||
/// <param name="bounds"></param>
|
||||
public void SetContentBounds(Rectangle bounds) => this.CallMethod1(JObject.FromObject(bounds, _jsonSerializer));
|
||||
public void SetContentBounds(Rectangle bounds) => this.CallMethod1(bounds);
|
||||
|
||||
/// <summary>
|
||||
/// Resizes and moves the window’s client area (e.g. the web page) to the supplied bounds.
|
||||
/// </summary>
|
||||
/// <param name="bounds"></param>
|
||||
/// <param name="animate"></param>
|
||||
public void SetContentBounds(Rectangle bounds, bool animate) => this.CallMethod2(JObject.FromObject(bounds, _jsonSerializer), animate);
|
||||
public void SetContentBounds(Rectangle bounds, bool animate) => this.CallMethod2(bounds, animate);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the content bounds asynchronous.
|
||||
@@ -749,10 +743,10 @@ public class BrowserWindow : ApiBase
|
||||
{
|
||||
// Workaround Windows 10 / Electron Bug
|
||||
// https://github.com/electron/electron/issues/4045
|
||||
////if (isWindows10())
|
||||
////{
|
||||
//// x = x - 7;
|
||||
////}
|
||||
//if (isWindows10())
|
||||
//{
|
||||
// x = x - 7;
|
||||
//}
|
||||
this.CallMethod2(x, y);
|
||||
}
|
||||
|
||||
@@ -766,10 +760,11 @@ public class BrowserWindow : ApiBase
|
||||
{
|
||||
// Workaround Windows 10 / Electron Bug
|
||||
// https://github.com/electron/electron/issues/4045
|
||||
////if (isWindows10())
|
||||
////{
|
||||
//// x = x - 7;
|
||||
////}
|
||||
//if (isWindows10())
|
||||
//{
|
||||
// x = x - 7;
|
||||
//}
|
||||
|
||||
this.CallMethod3(x, y, animate);
|
||||
}
|
||||
|
||||
@@ -894,7 +889,7 @@ public class BrowserWindow : ApiBase
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="options"></param>
|
||||
public void LoadURL(string url, LoadURLOptions options) => this.CallMethod2(url, JObject.FromObject(options, _jsonSerializer));
|
||||
public void LoadURL(string url, LoadURLOptions options) => this.CallMethod2(url, options);
|
||||
|
||||
/// <summary>
|
||||
/// Same as webContents.reload.
|
||||
@@ -925,13 +920,13 @@ public class BrowserWindow : ApiBase
|
||||
public void SetMenu(MenuItem[] menuItems)
|
||||
{
|
||||
menuItems.AddMenuItemsId();
|
||||
this.CallMethod1(JArray.FromObject(menuItems, _jsonSerializer));
|
||||
this.CallMethod1(menuItems);
|
||||
_items.AddRange(menuItems);
|
||||
|
||||
BridgeConnector.Socket.Off("windowMenuItemClicked");
|
||||
BridgeConnector.Socket.On("windowMenuItemClicked", (id) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("windowMenuItemClicked", (id) =>
|
||||
{
|
||||
MenuItem menuItem = _items.GetMenuItem(id.ToString());
|
||||
MenuItem menuItem = _items.GetMenuItem(id.GetString());
|
||||
menuItem?.Click();
|
||||
});
|
||||
}
|
||||
@@ -967,7 +962,7 @@ public class BrowserWindow : ApiBase
|
||||
/// <param name="progress"></param>
|
||||
/// <param name="progressBarOptions"></param>
|
||||
public void SetProgressBar(double progress, ProgressBarOptions progressBarOptions) =>
|
||||
this.CallMethod2(progress, JObject.FromObject(progressBarOptions, _jsonSerializer));
|
||||
this.CallMethod2(progress, progressBarOptions);
|
||||
|
||||
/// <summary>
|
||||
/// Sets whether the window should have a shadow. On Windows and Linux does nothing.
|
||||
@@ -1015,22 +1010,22 @@ public class BrowserWindow : ApiBase
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("browserWindowSetThumbarButtons-completed", (success) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("browserWindowSetThumbarButtons-completed", (success) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindowSetThumbarButtons-completed");
|
||||
|
||||
taskCompletionSource.SetResult((bool)success);
|
||||
taskCompletionSource.SetResult(success.GetBoolean());
|
||||
});
|
||||
|
||||
thumbarButtons.AddThumbarButtonsId();
|
||||
BridgeConnector.Socket.Emit("browserWindowSetThumbarButtons", Id, JArray.FromObject(thumbarButtons, _jsonSerializer));
|
||||
BridgeConnector.Socket.Emit("browserWindowSetThumbarButtons", Id, thumbarButtons);
|
||||
_thumbarButtons.Clear();
|
||||
_thumbarButtons.AddRange(thumbarButtons);
|
||||
|
||||
BridgeConnector.Socket.Off("thumbarButtonClicked");
|
||||
BridgeConnector.Socket.On("thumbarButtonClicked", (id) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("thumbarButtonClicked", (id) =>
|
||||
{
|
||||
ThumbarButton thumbarButton = _thumbarButtons.GetThumbarButton(id.ToString());
|
||||
ThumbarButton thumbarButton = _thumbarButtons.GetThumbarButton(id.GetString());
|
||||
thumbarButton?.Click();
|
||||
});
|
||||
|
||||
@@ -1058,7 +1053,7 @@ public class BrowserWindow : ApiBase
|
||||
/// If one of those properties is not set, then neither will be used.
|
||||
/// </summary>
|
||||
/// <param name="options"></param>
|
||||
public void SetAppDetails(AppDetailsOptions options) => this.CallMethod1(JObject.FromObject(options, _jsonSerializer));
|
||||
public void SetAppDetails(AppDetailsOptions options) => this.CallMethod1(options);
|
||||
|
||||
/// <summary>
|
||||
/// Same as webContents.showDefinitionForSelection().
|
||||
@@ -1146,7 +1141,7 @@ public class BrowserWindow : ApiBase
|
||||
}
|
||||
else
|
||||
{
|
||||
BridgeConnector.Socket.Emit("browserWindowSetParentWindow", Id, JObject.FromObject(parent, _jsonSerializer));
|
||||
BridgeConnector.Socket.Emit("browserWindowSetParentWindow", Id, parent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1210,10 +1205,4 @@ public class BrowserWindow : ApiBase
|
||||
// This message name does not match the default ApiBase naming convention.
|
||||
BridgeConnector.Socket.Emit("browserWindow-setBrowserView", Id, browserView.Id);
|
||||
}
|
||||
|
||||
private readonly JsonSerializer _jsonSerializer = new()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
using ElectronNET.API.Entities;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using ElectronNET.API.Entities;
|
||||
using ElectronNET.API.Serialization;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API
|
||||
@@ -46,11 +45,11 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
BridgeConnector.Socket.On("clipboard-readText-Completed", (text) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("clipboard-readText-Completed", (text) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("clipboard-readText-Completed");
|
||||
|
||||
taskCompletionSource.SetResult(text.ToString());
|
||||
taskCompletionSource.SetResult(text.GetString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("clipboard-readText", type);
|
||||
@@ -77,11 +76,11 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
BridgeConnector.Socket.On("clipboard-readHTML-Completed", (text) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("clipboard-readHTML-Completed", (text) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("clipboard-readHTML-Completed");
|
||||
|
||||
taskCompletionSource.SetResult(text.ToString());
|
||||
taskCompletionSource.SetResult(text.GetString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("clipboard-readHTML", type);
|
||||
@@ -108,11 +107,11 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
BridgeConnector.Socket.On("clipboard-readRTF-Completed", (text) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("clipboard-readRTF-Completed", (text) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("clipboard-readRTF-Completed");
|
||||
|
||||
taskCompletionSource.SetResult(text.ToString());
|
||||
taskCompletionSource.SetResult(text.GetString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("clipboard-readRTF", type);
|
||||
@@ -140,11 +139,11 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<ReadBookmark>();
|
||||
|
||||
BridgeConnector.Socket.On("clipboard-readBookmark-Completed", (bookmark) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("clipboard-readBookmark-Completed", (bookmark) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("clipboard-readBookmark-Completed");
|
||||
|
||||
taskCompletionSource.SetResult(((JObject)bookmark).ToObject<ReadBookmark>());
|
||||
taskCompletionSource.SetResult(JsonSerializer.Deserialize<ReadBookmark>(bookmark, ElectronJson.Options));
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("clipboard-readBookmark");
|
||||
@@ -177,11 +176,11 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
BridgeConnector.Socket.On("clipboard-readFindText-Completed", (text) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("clipboard-readFindText-Completed", (text) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("clipboard-readFindText-Completed");
|
||||
|
||||
taskCompletionSource.SetResult(text.ToString());
|
||||
taskCompletionSource.SetResult(text.GetString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("clipboard-readFindText");
|
||||
@@ -217,11 +216,11 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string[]>();
|
||||
|
||||
BridgeConnector.Socket.On("clipboard-availableFormats-Completed", (formats) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("clipboard-availableFormats-Completed", (formats) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("clipboard-availableFormats-Completed");
|
||||
|
||||
taskCompletionSource.SetResult(((JArray)formats).ToObject<string[]>());
|
||||
taskCompletionSource.SetResult(JsonSerializer.Deserialize<string[]>(formats, ElectronJson.Options));
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("clipboard-availableFormats", type);
|
||||
@@ -236,7 +235,7 @@ namespace ElectronNET.API
|
||||
/// <param name="type"></param>
|
||||
public void Write(Data data, string type = "")
|
||||
{
|
||||
BridgeConnector.Socket.Emit("clipboard-write", JObject.FromObject(data, _jsonSerializer), type);
|
||||
BridgeConnector.Socket.Emit("clipboard-write", data, type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -248,11 +247,11 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<NativeImage>();
|
||||
|
||||
BridgeConnector.Socket.On("clipboard-readImage-Completed", (image) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("clipboard-readImage-Completed", (image) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("clipboard-readImage-Completed");
|
||||
|
||||
var nativeImage = ((JObject)image).ToObject<NativeImage>();
|
||||
var nativeImage = image.Deserialize<NativeImage>(ElectronJson.Options);
|
||||
|
||||
taskCompletionSource.SetResult(nativeImage);
|
||||
});
|
||||
@@ -269,14 +268,7 @@ namespace ElectronNET.API
|
||||
/// <param name="type"></param>
|
||||
public void WriteImage(NativeImage image, string type = "")
|
||||
{
|
||||
BridgeConnector.Socket.Emit("clipboard-writeImage", JsonConvert.SerializeObject(image), type);
|
||||
BridgeConnector.Socket.Emit("clipboard-writeImage", JsonSerializer.Serialize(image, ElectronJson.Options), type);
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Threading;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API
|
||||
@@ -75,10 +76,10 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.Socket.On("appCommandLineHasSwitchCompleted", (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("appCommandLineHasSwitchCompleted", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("appCommandLineHasSwitchCompleted");
|
||||
taskCompletionSource.SetResult((bool)result);
|
||||
taskCompletionSource.SetResult(result.GetBoolean());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("appCommandLineHasSwitch", switchName);
|
||||
@@ -103,10 +104,10 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.Socket.On("appCommandLineGetSwitchValueCompleted", (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("appCommandLineGetSwitchValueCompleted", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("appCommandLineGetSwitchValueCompleted");
|
||||
taskCompletionSource.SetResult((string)result);
|
||||
taskCompletionSource.SetResult(result.GetString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("appCommandLineGetSwitchValue", switchName);
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using ElectronNET.API.Entities;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
@@ -34,11 +30,15 @@ namespace ElectronNET.API
|
||||
{
|
||||
if (_changed == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("webContents-session-cookies-changed" + Id, (args) =>
|
||||
BridgeConnector.Socket.On<System.Text.Json.JsonElement>("webContents-session-cookies-changed" + Id, (args) =>
|
||||
{
|
||||
Cookie cookie = ((JArray)args)[0].ToObject<Cookie>();
|
||||
CookieChangedCause cause = ((JArray)args)[1].ToObject<CookieChangedCause>();
|
||||
bool removed = ((JArray)args)[2].ToObject<bool>();
|
||||
var e = args.EnumerateArray().GetEnumerator();
|
||||
e.MoveNext();
|
||||
var cookie = System.Text.Json.JsonSerializer.Deserialize<Cookie>(e.Current, Serialization.ElectronJson.Options);
|
||||
e.MoveNext();
|
||||
var cause = System.Text.Json.JsonSerializer.Deserialize<CookieChangedCause>(e.Current, Serialization.ElectronJson.Options);
|
||||
e.MoveNext();
|
||||
var removed = e.Current.GetBoolean();
|
||||
_changed(cookie, cause, removed);
|
||||
});
|
||||
|
||||
@@ -58,11 +58,6 @@ namespace ElectronNET.API
|
||||
|
||||
private event Action<Cookie, CookieChangedCause, bool> _changed;
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
using ElectronNET.API.Entities;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using ElectronNET.API.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API
|
||||
@@ -52,18 +49,17 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<string[]>();
|
||||
var guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("showOpenDialogComplete" + guid, (filePaths) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("showOpenDialogComplete" + guid, (filePaths) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("showOpenDialogComplete" + guid);
|
||||
|
||||
var result = ((JArray)filePaths).ToObject<string[]>();
|
||||
var result = JsonSerializer.Deserialize<string[]>(filePaths, Serialization.ElectronJson.Options);
|
||||
taskCompletionSource.SetResult(result);
|
||||
});
|
||||
|
||||
|
||||
BridgeConnector.Socket.Emit("showOpenDialog",
|
||||
JObject.FromObject(browserWindow, _jsonSerializer),
|
||||
JObject.FromObject(options, _jsonSerializer), guid);
|
||||
browserWindow,
|
||||
options, guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
@@ -79,16 +75,16 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
var guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("showSaveDialogComplete" + guid, (filename) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("showSaveDialogComplete" + guid, (filename) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("showSaveDialogComplete" + guid);
|
||||
|
||||
taskCompletionSource.SetResult(filename.ToString());
|
||||
taskCompletionSource.SetResult(filename.GetString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("showSaveDialog",
|
||||
JObject.FromObject(browserWindow, _jsonSerializer),
|
||||
JObject.FromObject(options, _jsonSerializer),
|
||||
browserWindow,
|
||||
options,
|
||||
guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
@@ -148,28 +144,34 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<MessageBoxResult>();
|
||||
var guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("showMessageBoxComplete" + guid, (args) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("showMessageBoxComplete" + guid, (args) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("showMessageBoxComplete" + guid);
|
||||
|
||||
var result = ((JArray)args);
|
||||
// args is [response:int, checkboxChecked:boolean]
|
||||
var arr = args.EnumerateArray();
|
||||
var e = arr.GetEnumerator();
|
||||
e.MoveNext();
|
||||
var response = e.Current.GetInt32();
|
||||
e.MoveNext();
|
||||
var checkbox = e.Current.GetBoolean();
|
||||
|
||||
taskCompletionSource.SetResult(new MessageBoxResult
|
||||
{
|
||||
Response = (int)result.First,
|
||||
CheckboxChecked = (bool)result.Last
|
||||
Response = response,
|
||||
CheckboxChecked = checkbox
|
||||
});
|
||||
});
|
||||
|
||||
if (browserWindow == null)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("showMessageBox", JObject.FromObject(messageBoxOptions, _jsonSerializer), guid);
|
||||
BridgeConnector.Socket.Emit("showMessageBox", messageBoxOptions, guid);
|
||||
}
|
||||
else
|
||||
{
|
||||
BridgeConnector.Socket.Emit("showMessageBox",
|
||||
JObject.FromObject(browserWindow, _jsonSerializer),
|
||||
JObject.FromObject(messageBoxOptions, _jsonSerializer),
|
||||
browserWindow,
|
||||
messageBoxOptions,
|
||||
guid);
|
||||
}
|
||||
|
||||
@@ -223,18 +225,13 @@ namespace ElectronNET.API
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("showCertificateTrustDialog",
|
||||
JObject.FromObject(browserWindow, _jsonSerializer),
|
||||
JObject.FromObject(options, _jsonSerializer),
|
||||
browserWindow,
|
||||
options,
|
||||
guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using ElectronNET.API.Entities;
|
||||
using ElectronNET.API.Extensions;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
@@ -57,10 +55,10 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<int>();
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.Socket.On("dock-bounce-completed", (id) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("dock-bounce-completed", (id) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("dock-bounce-completed");
|
||||
taskCompletionSource.SetResult((int)id);
|
||||
taskCompletionSource.SetResult(id.GetInt32());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("dock-bounce", type.GetDescription());
|
||||
@@ -109,10 +107,10 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.Socket.On("dock-getBadge-completed", (text) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("dock-getBadge-completed", (text) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("dock-getBadge-completed");
|
||||
taskCompletionSource.SetResult((string)text);
|
||||
taskCompletionSource.SetResult(text.GetString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("dock-getBadge");
|
||||
@@ -151,10 +149,10 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.Socket.On("dock-isVisible-completed", (isVisible) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("dock-isVisible-completed", (isVisible) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("dock-isVisible-completed");
|
||||
taskCompletionSource.SetResult((bool)isVisible);
|
||||
taskCompletionSource.SetResult(isVisible.GetBoolean());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("dock-isVisible");
|
||||
@@ -186,13 +184,13 @@ namespace ElectronNET.API
|
||||
public void SetMenu(MenuItem[] menuItems)
|
||||
{
|
||||
menuItems.AddMenuItemsId();
|
||||
BridgeConnector.Socket.Emit("dock-setMenu", JArray.FromObject(menuItems, _jsonSerializer));
|
||||
BridgeConnector.Socket.Emit("dock-setMenu", menuItems);
|
||||
_items.AddRange(menuItems);
|
||||
|
||||
BridgeConnector.Socket.Off("dockMenuItemClicked");
|
||||
BridgeConnector.Socket.On("dockMenuItemClicked", (id) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("dockMenuItemClicked", (id) =>
|
||||
{
|
||||
MenuItem menuItem = _items.GetMenuItem(id.ToString());
|
||||
MenuItem menuItem = _items.GetMenuItem(id.GetString());
|
||||
menuItem?.Click();
|
||||
});
|
||||
}
|
||||
@@ -208,10 +206,10 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<Menu>();
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.Socket.On("dock-getMenu-completed", (menu) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("dock-getMenu-completed", (menu) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("dock-getMenu-completed");
|
||||
taskCompletionSource.SetResult(((JObject)menu).ToObject<Menu>());
|
||||
taskCompletionSource.SetResult(JsonSerializer.Deserialize<Menu>(menu, Serialization.ElectronJson.Options));
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("dock-getMenu");
|
||||
@@ -230,10 +228,6 @@ namespace ElectronNET.API
|
||||
BridgeConnector.Socket.Emit("dock-setIcon", image);
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using ElectronNET.Converter;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using ElectronNET.Converter;
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
@@ -213,7 +213,7 @@ namespace ElectronNET.API.Entities
|
||||
/// The style of window title bar. Default is default. Possible values are:
|
||||
/// 'default' | 'hidden' | 'hiddenInset' | 'customButtonsOnHover'
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public TitleBarStyle TitleBarStyle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -256,7 +256,7 @@ namespace ElectronNET.API.Entities
|
||||
/// appearance-based, light, dark, titlebar, selection, menu, popover, sidebar,
|
||||
/// medium-light or ultra-dark.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public Vibrancy Vibrancy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -294,3 +294,7 @@ namespace ElectronNET.API.Entities
|
||||
public string ProxyCredentials { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
/// <summary>
|
||||
/// Percentage of CPU used since the last call to getCPUUsage. First call returns 0.
|
||||
/// </summary>
|
||||
public int PercentCPUUsage { get; set; }
|
||||
public double PercentCPUUsage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of average idle cpu wakeups per second since the last call to
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Provide metadata about the current loaded Chrome extension
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// The cause of the change
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public enum CookieChangedCause
|
||||
{
|
||||
/// <summary>
|
||||
///The cookie was changed directly by a consumer's action.
|
||||
/// </summary>
|
||||
[JsonProperty("explicit")]
|
||||
[JsonPropertyName("explicit")]
|
||||
@explicit,
|
||||
|
||||
/// <summary>
|
||||
@@ -33,7 +33,7 @@ namespace ElectronNET.API.Entities
|
||||
/// <summary>
|
||||
/// The cookie was overwritten with an already-expired expiration date.
|
||||
/// </summary>
|
||||
[JsonProperty("expired_overwrite")]
|
||||
[JsonPropertyName("expired_overwrite")]
|
||||
expiredOverwrite
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
/// <summary>
|
||||
/// Unique identifier associated with the display.
|
||||
/// </summary>
|
||||
public string Id { get; set; }
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// true for an internal display and false for an external display.
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Docs: https://electronjs.org/docs/api/structures/extension
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
@@ -10,43 +11,43 @@ namespace ElectronNET.API.Entities
|
||||
/// <summary>
|
||||
/// Canvas.
|
||||
/// </summary>
|
||||
[JsonProperty("2d_canvas")]
|
||||
[JsonPropertyName("2d_canvas")]
|
||||
public string Canvas { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Flash.
|
||||
/// </summary>
|
||||
[JsonProperty("flash_3d")]
|
||||
[JsonPropertyName("flash_3d")]
|
||||
public string Flash3D { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Flash Stage3D.
|
||||
/// </summary>
|
||||
[JsonProperty("flash_stage3d")]
|
||||
[JsonPropertyName("flash_stage3d")]
|
||||
public string FlashStage3D { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Flash Stage3D Baseline profile.
|
||||
/// </summary>
|
||||
[JsonProperty("flash_stage3d_baseline")]
|
||||
[JsonPropertyName("flash_stage3d_baseline")]
|
||||
public string FlashStage3dBaseline { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Compositing.
|
||||
/// </summary>
|
||||
[JsonProperty("gpu_compositing")]
|
||||
[JsonPropertyName("gpu_compositing")]
|
||||
public string GpuCompositing { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Multiple Raster Threads.
|
||||
/// </summary>
|
||||
[JsonProperty("multiple_raster_threads")]
|
||||
[JsonPropertyName("multiple_raster_threads")]
|
||||
public string MultipleRasterThreads { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Native GpuMemoryBuffers.
|
||||
/// </summary>
|
||||
[JsonProperty("native_gpu_memory_buffers")]
|
||||
[JsonPropertyName("native_gpu_memory_buffers")]
|
||||
public string NativeGpuMemoryBuffers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -57,19 +58,19 @@ namespace ElectronNET.API.Entities
|
||||
/// <summary>
|
||||
/// Video Decode.
|
||||
/// </summary>
|
||||
[JsonProperty("video_decode")]
|
||||
[JsonPropertyName("video_decode")]
|
||||
public string VideoDecode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Video Encode.
|
||||
/// </summary>
|
||||
[JsonProperty("video_encode")]
|
||||
[JsonPropertyName("video_encode")]
|
||||
public string VideoEncode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// VPx Video Decode.
|
||||
/// </summary>
|
||||
[JsonProperty("vpx_decode")]
|
||||
[JsonPropertyName("vpx_decode")]
|
||||
public string VpxDecode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
using ElectronNET.Converter;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -76,7 +75,9 @@ namespace ElectronNET.API.Entities
|
||||
/// `touchScrollStarted`, `pointerDown`, `pointerUp`, `pointerMove`,
|
||||
/// `pointerRawUpdate`, `pointerCancel` or `pointerCausedUaAction`.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public InputEventType Type { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
using System;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
internal class JsonPropertyAttribute : Attribute
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
@@ -21,7 +21,8 @@ namespace ElectronNET.API.Entities
|
||||
/// <summary>
|
||||
/// One of the following: "tasks" | "frequent" | "recent" | "custom"
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public JumpListCategoryType Type { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
@@ -52,7 +52,9 @@ namespace ElectronNET.API.Entities
|
||||
/// <summary>
|
||||
/// One of the following: "task" | "separator" | "file"
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public JumpListItemType Type { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
@@ -21,13 +19,13 @@ namespace ElectronNET.API.Entities
|
||||
/// Define the action of the menu item, when specified the click property will be
|
||||
/// ignored.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public MenuRole Role { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Can be normal, separator, submenu, checkbox or radio.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public MenuType Type { get; set; }
|
||||
|
||||
|
||||
@@ -101,3 +99,5 @@ namespace ElectronNET.API.Entities
|
||||
public string Position { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
@@ -13,7 +13,7 @@ namespace ElectronNET.API.Entities
|
||||
/// displays the same icon as "info", unless you set an icon using the "icon"
|
||||
/// option. On macOS, both "warning" and "error" display the same warning icon.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public MessageBoxType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -99,3 +99,5 @@ namespace ElectronNET.API.Entities
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Text.RegularExpressions;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
|
||||
@@ -1,25 +1,29 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
internal class NativeImageJsonConverter : JsonConverter
|
||||
internal class NativeImageJsonConverter : JsonConverter<NativeImage>
|
||||
{
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
public override void Write(Utf8JsonWriter writer, NativeImage value, JsonSerializerOptions options)
|
||||
{
|
||||
if (value is NativeImage nativeImage)
|
||||
if (value is null)
|
||||
{
|
||||
var scaledImages = nativeImage.GetAllScaledImages();
|
||||
serializer.Serialize(writer, scaledImages);
|
||||
writer.WriteNullValue();
|
||||
return;
|
||||
}
|
||||
|
||||
var scaledImages = value.GetAllScaledImages();
|
||||
JsonSerializer.Serialize(writer, scaledImages, Serialization.ElectronJson.Options);
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
public override NativeImage Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
var dict = serializer.Deserialize<Dictionary<float, string>>(reader);
|
||||
var dict = JsonSerializer.Deserialize<Dictionary<float, string>>(ref reader, Serialization.ElectronJson.Options);
|
||||
var newDictionary = new Dictionary<float, Image>();
|
||||
foreach (var item in dict)
|
||||
{
|
||||
@@ -29,7 +33,6 @@ namespace ElectronNET.API.Entities
|
||||
|
||||
return new NativeImage(newDictionary);
|
||||
}
|
||||
|
||||
public override bool CanConvert(Type objectType) => objectType == typeof(NativeImage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
@@ -13,7 +13,8 @@ namespace ElectronNET.API.Entities
|
||||
/// detach.Defaults to last used dock state.In undocked mode it's possible to dock
|
||||
/// back.In detach mode it's not.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public DevToolsMode Mode { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
@@ -33,7 +33,7 @@ namespace ElectronNET.API.Entities
|
||||
/// Contains which features the dialog should use. The following values are supported:
|
||||
/// 'openFile' | 'openDirectory' | 'multiSelections' | 'showHiddenFiles' | 'createDirectory' | 'promptToCreate' | 'noResolveAliases' | 'treatPackageAsDirectory'
|
||||
/// </summary>
|
||||
[JsonProperty("properties", ItemConverterType = typeof(StringEnumConverter))]
|
||||
[JsonPropertyName("properties")]
|
||||
public OpenDialogProperty[] Properties { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -58,4 +58,5 @@ namespace ElectronNET.API.Entities
|
||||
/// </example>
|
||||
public FileFilter[] Filters { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using ElectronNET.Converter;
|
||||
using Newtonsoft.Json;
|
||||
using ElectronNET.Converter;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
@@ -11,7 +11,8 @@ namespace ElectronNET.API.Entities
|
||||
/// <summary>
|
||||
/// Mode for the progress bar. Can be 'none' | 'normal' | 'indeterminate' | 'error' | 'paused'.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public ProgressBarMode Mode { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
@@ -28,7 +28,7 @@ namespace ElectronNET.API.Entities
|
||||
/// Scheme of the authentication. Can be basic, digest, ntlm, negotiate.
|
||||
/// Must be provided if removing by origin.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public Scheme Scheme { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -51,3 +51,5 @@ namespace ElectronNET.API.Entities
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
@@ -36,7 +35,7 @@ namespace ElectronNET.API.Entities
|
||||
/// hidden - The button is not shown to the user.
|
||||
/// noninteractive - The button is enabled but not interactive; no pressed button state is drawn.This value is intended for instances where the button is used in a notification.
|
||||
/// </summary>
|
||||
[JsonProperty("flags", ItemConverterType = typeof(StringEnumConverter))]
|
||||
[JsonPropertyName("flags")]
|
||||
public ThumbarButtonFlag[] Flags { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -58,4 +57,5 @@ namespace ElectronNET.API.Entities
|
||||
Icon = icon;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
@@ -10,7 +11,7 @@ namespace ElectronNET.API.Entities
|
||||
/// <summary>
|
||||
/// The default style
|
||||
/// </summary>
|
||||
[JsonProperty("default")]
|
||||
[JsonPropertyName("default")]
|
||||
defaultStyle,
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API
|
||||
@@ -52,11 +53,11 @@ namespace ElectronNET.API
|
||||
_shortcuts.Add(accelerator, function);
|
||||
|
||||
BridgeConnector.Socket.Off("globalShortcut-pressed");
|
||||
BridgeConnector.Socket.On("globalShortcut-pressed", (shortcut) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("globalShortcut-pressed", (shortcut) =>
|
||||
{
|
||||
if (_shortcuts.ContainsKey(shortcut.ToString()))
|
||||
if (_shortcuts.TryGetValue(shortcut.GetString(), out var action))
|
||||
{
|
||||
_shortcuts[shortcut.ToString()]();
|
||||
action();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -74,11 +75,11 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("globalShortcut-isRegisteredCompleted", (isRegistered) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("globalShortcut-isRegisteredCompleted", (isRegistered) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("globalShortcut-isRegisteredCompleted");
|
||||
|
||||
taskCompletionSource.SetResult((bool)isRegistered);
|
||||
taskCompletionSource.SetResult(isRegistered.GetBoolean());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("globalShortcut-isRegistered", accelerator);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API
|
||||
@@ -49,10 +47,10 @@ namespace ElectronNET.API
|
||||
/// <param name="arguments">Optional parameters.</param>
|
||||
public void Call(string socketEventName, params dynamic[] arguments)
|
||||
{
|
||||
BridgeConnector.Socket.On(socketEventName + "Error" + oneCallguid, (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>(socketEventName + "Error" + oneCallguid, (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off(socketEventName + "Error" + oneCallguid);
|
||||
Electron.Dialog.ShowErrorBox("Host Hook Exception", result.ToString());
|
||||
Electron.Dialog.ShowErrorBox("Host Hook Exception", result.GetString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit(socketEventName, arguments, oneCallguid);
|
||||
@@ -70,14 +68,14 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<T>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On(socketEventName + "Error" + guid, (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>(socketEventName + "Error" + guid, (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off(socketEventName + "Error" + guid);
|
||||
Electron.Dialog.ShowErrorBox("Host Hook Exception", result.ToString());
|
||||
Electron.Dialog.ShowErrorBox("Host Hook Exception", result.GetString());
|
||||
taskCompletionSource.SetException(new Exception($"Host Hook Exception {result}"));
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.On(socketEventName + "Complete" + guid, (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>(socketEventName + "Complete" + guid, (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off(socketEventName + "Error" + guid);
|
||||
BridgeConnector.Socket.Off(socketEventName + "Complete" + guid);
|
||||
@@ -85,26 +83,7 @@ namespace ElectronNET.API
|
||||
|
||||
try
|
||||
{
|
||||
if (result.GetType().IsValueType || result is string)
|
||||
{
|
||||
data = (T)result;
|
||||
}
|
||||
else
|
||||
{
|
||||
var token = JToken.Parse(result.ToString());
|
||||
if (token is JArray)
|
||||
{
|
||||
data = token.ToObject<T>();
|
||||
}
|
||||
else if (token is JObject)
|
||||
{
|
||||
data = token.ToObject<T>();
|
||||
}
|
||||
else
|
||||
{
|
||||
data = (T)result;
|
||||
}
|
||||
}
|
||||
data = result.Deserialize<T>(Serialization.ElectronJson.Options);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@@ -120,11 +99,6 @@ namespace ElectronNET.API
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@@ -50,7 +46,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
await BridgeConnector.Socket.Emit("registerIpcMainChannel", channel).ConfigureAwait(false);
|
||||
BridgeConnector.Socket.Off(channel);
|
||||
BridgeConnector.Socket.On(channel, (args) =>
|
||||
BridgeConnector.Socket.On<System.Text.Json.JsonElement>(channel, (args) =>
|
||||
{
|
||||
List<object> objectArray = FormatArguments(args);
|
||||
|
||||
@@ -65,19 +61,10 @@ namespace ElectronNET.API
|
||||
});
|
||||
}
|
||||
|
||||
private List<object> FormatArguments(object args)
|
||||
private static List<object> FormatArguments(System.Text.Json.JsonElement args)
|
||||
{
|
||||
List<object> objectArray = ((JArray)args).ToObject<object[]>().ToList();
|
||||
|
||||
for (int index = 0; index < objectArray.Count; index++)
|
||||
{
|
||||
var item = objectArray[index];
|
||||
if (item == null)
|
||||
{
|
||||
objectArray.Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
var objectArray = System.Text.Json.JsonSerializer.Deserialize<object[]>(args, Serialization.ElectronJson.Options).ToList();
|
||||
objectArray.RemoveAll(item => item is null);
|
||||
return objectArray;
|
||||
}
|
||||
|
||||
@@ -93,7 +80,7 @@ namespace ElectronNET.API
|
||||
public void OnSync(string channel, Func<object, object> listener)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("registerSyncIpcMainChannel", channel);
|
||||
BridgeConnector.Socket.On(channel, (args) =>
|
||||
BridgeConnector.Socket.On<System.Text.Json.JsonElement>(channel, (args) =>
|
||||
{
|
||||
List<object> objectArray = FormatArguments(args);
|
||||
object parameter;
|
||||
@@ -120,7 +107,7 @@ namespace ElectronNET.API
|
||||
public void Once(string channel, Action<object> listener)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("registerOnceIpcMainChannel", channel);
|
||||
BridgeConnector.Socket.Once<object>(channel, (args) =>
|
||||
BridgeConnector.Socket.Once<System.Text.Json.JsonElement>(channel, (args) =>
|
||||
{
|
||||
List<object> objectArray = FormatArguments(args);
|
||||
|
||||
@@ -155,34 +142,7 @@ namespace ElectronNET.API
|
||||
/// <param name="data">Arguments data.</param>
|
||||
public void Send(BrowserWindow browserWindow, string channel, params object[] data)
|
||||
{
|
||||
List<JObject> jobjects = new List<JObject>();
|
||||
List<JArray> jarrays = new List<JArray>();
|
||||
List<object> objects = new List<object>();
|
||||
|
||||
foreach (var parameterObject in data)
|
||||
{
|
||||
if (parameterObject.GetType().IsArray || parameterObject.GetType().IsGenericType && parameterObject is IEnumerable)
|
||||
{
|
||||
jarrays.Add(JArray.FromObject(parameterObject, _jsonSerializer));
|
||||
}
|
||||
else if (parameterObject.GetType().IsClass && !parameterObject.GetType().IsPrimitive && !(parameterObject is string))
|
||||
{
|
||||
jobjects.Add(JObject.FromObject(parameterObject, _jsonSerializer));
|
||||
}
|
||||
else if (parameterObject.GetType().IsPrimitive || (parameterObject is string))
|
||||
{
|
||||
objects.Add(parameterObject);
|
||||
}
|
||||
}
|
||||
|
||||
if (jobjects.Count > 0 || jarrays.Count > 0)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("sendToIpcRenderer", JObject.FromObject(browserWindow, _jsonSerializer), channel, jarrays.ToArray(), jobjects.ToArray(), objects.ToArray());
|
||||
}
|
||||
else
|
||||
{
|
||||
BridgeConnector.Socket.Emit("sendToIpcRenderer", JObject.FromObject(browserWindow, _jsonSerializer), channel, data);
|
||||
}
|
||||
BridgeConnector.Socket.Emit("sendToIpcRenderer", browserWindow, channel, data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -196,41 +156,9 @@ namespace ElectronNET.API
|
||||
/// <param name="data">Arguments data.</param>
|
||||
public void Send(BrowserView browserView, string channel, params object[] data)
|
||||
{
|
||||
List<JObject> jobjects = new List<JObject>();
|
||||
List<JArray> jarrays = new List<JArray>();
|
||||
List<object> objects = new List<object>();
|
||||
|
||||
foreach (var parameterObject in data)
|
||||
{
|
||||
if (parameterObject.GetType().IsArray || parameterObject.GetType().IsGenericType && parameterObject is IEnumerable)
|
||||
{
|
||||
jarrays.Add(JArray.FromObject(parameterObject, _jsonSerializer));
|
||||
}
|
||||
else if (parameterObject.GetType().IsClass && !parameterObject.GetType().IsPrimitive && !(parameterObject is string))
|
||||
{
|
||||
jobjects.Add(JObject.FromObject(parameterObject, _jsonSerializer));
|
||||
}
|
||||
else if (parameterObject.GetType().IsPrimitive || (parameterObject is string))
|
||||
{
|
||||
objects.Add(parameterObject);
|
||||
}
|
||||
}
|
||||
|
||||
if (jobjects.Count > 0 || jarrays.Count > 0)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("sendToIpcRendererBrowserView", browserView.Id, channel, jarrays.ToArray(), jobjects.ToArray(), objects.ToArray());
|
||||
}
|
||||
else
|
||||
{
|
||||
BridgeConnector.Socket.Emit("sendToIpcRendererBrowserView", browserView.Id, channel, data);
|
||||
}
|
||||
BridgeConnector.Socket.Emit("sendToIpcRendererBrowserView", browserView.Id, channel, data);
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
using ElectronNET.API.Entities;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using ElectronNET.API.Entities;
|
||||
using ElectronNET.API.Extensions;
|
||||
using System.Linq;
|
||||
using ElectronNET.API.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
@@ -67,13 +66,13 @@ namespace ElectronNET.API
|
||||
menuItems.AddMenuItemsId();
|
||||
menuItems.AddSubmenuTypes();
|
||||
|
||||
BridgeConnector.Socket.Emit("menu-setApplicationMenu", JArray.FromObject(menuItems, _jsonSerializer));
|
||||
BridgeConnector.Socket.Emit("menu-setApplicationMenu", JsonSerializer.SerializeToNode(menuItems, ElectronJson.Options));
|
||||
_menuItems.AddRange(menuItems);
|
||||
|
||||
BridgeConnector.Socket.Off("menuItemClicked");
|
||||
BridgeConnector.Socket.On("menuItemClicked", (id) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("menuItemClicked", (id) =>
|
||||
{
|
||||
MenuItem menuItem = _menuItems.GetMenuItem(id.ToString());
|
||||
MenuItem menuItem = _menuItems.GetMenuItem(id.GetString());
|
||||
menuItem.Click?.Invoke();
|
||||
});
|
||||
}
|
||||
@@ -98,7 +97,7 @@ namespace ElectronNET.API
|
||||
menuItems.AddMenuItemsId();
|
||||
menuItems.AddSubmenuTypes();
|
||||
|
||||
BridgeConnector.Socket.Emit("menu-setContextMenu", browserWindow.Id, JArray.FromObject(menuItems, _jsonSerializer));
|
||||
BridgeConnector.Socket.Emit("menu-setContextMenu", browserWindow.Id, menuItems);
|
||||
|
||||
if (!_contextMenuItems.ContainsKey(browserWindow.Id))
|
||||
{
|
||||
@@ -108,10 +107,14 @@ namespace ElectronNET.API
|
||||
}
|
||||
|
||||
BridgeConnector.Socket.Off("contextMenuItemClicked");
|
||||
BridgeConnector.Socket.On("contextMenuItemClicked", (results) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("contextMenuItemClicked", (results) =>
|
||||
{
|
||||
var id = ((JArray)results).First.ToString();
|
||||
var browserWindowId = (int)((JArray)results).Last;
|
||||
var arr = results.EnumerateArray();
|
||||
var e = arr.GetEnumerator();
|
||||
e.MoveNext();
|
||||
var id = e.Current.GetString();
|
||||
e.MoveNext();
|
||||
var browserWindowId = e.Current.GetInt32();
|
||||
|
||||
MenuItem menuItem = _contextMenuItems[browserWindowId].GetMenuItem(id);
|
||||
menuItem.Click?.Invoke();
|
||||
@@ -127,10 +130,6 @@ namespace ElectronNET.API
|
||||
BridgeConnector.Socket.Emit("menu-contextMenuPopup", browserWindow.Id);
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using ElectronNET.API.Entities;
|
||||
using ElectronNET.API.Entities;
|
||||
using ElectronNET.API.Extensions;
|
||||
using ElectronNET.Common;
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
@@ -108,11 +109,11 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<ThemeSourceMode>();
|
||||
|
||||
BridgeConnector.Socket.On("nativeTheme-themeSource-getCompleted", (themeSource) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("nativeTheme-themeSource-getCompleted", (themeSource) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("nativeTheme-themeSource-getCompleted");
|
||||
|
||||
var themeSourceValue = (ThemeSourceMode)Enum.Parse(typeof(ThemeSourceMode), (string)themeSource, true);
|
||||
var themeSourceValue = (ThemeSourceMode)Enum.Parse(typeof(ThemeSourceMode), themeSource.GetString(), true);
|
||||
|
||||
taskCompletionSource.SetResult(themeSourceValue);
|
||||
});
|
||||
@@ -131,11 +132,11 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("nativeTheme-shouldUseDarkColors-completed", (shouldUseDarkColors) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("nativeTheme-shouldUseDarkColors-completed", (shouldUseDarkColors) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("nativeTheme-shouldUseDarkColors-completed");
|
||||
|
||||
taskCompletionSource.SetResult((bool)shouldUseDarkColors);
|
||||
taskCompletionSource.SetResult(shouldUseDarkColors.GetBoolean());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("nativeTheme-shouldUseDarkColors");
|
||||
@@ -151,11 +152,11 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("nativeTheme-shouldUseHighContrastColors-completed", (shouldUseHighContrastColors) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("nativeTheme-shouldUseHighContrastColors-completed", (shouldUseHighContrastColors) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("nativeTheme-shouldUseHighContrastColors-completed");
|
||||
|
||||
taskCompletionSource.SetResult((bool)shouldUseHighContrastColors);
|
||||
taskCompletionSource.SetResult(shouldUseHighContrastColors.GetBoolean());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("nativeTheme-shouldUseHighContrastColors");
|
||||
@@ -171,11 +172,11 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("nativeTheme-shouldUseInvertedColorScheme-completed", (shouldUseInvertedColorScheme) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("nativeTheme-shouldUseInvertedColorScheme-completed", (shouldUseInvertedColorScheme) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("nativeTheme-shouldUseInvertedColorScheme-completed");
|
||||
|
||||
taskCompletionSource.SetResult((bool)shouldUseInvertedColorScheme);
|
||||
taskCompletionSource.SetResult(shouldUseInvertedColorScheme.GetBoolean());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("nativeTheme-shouldUseInvertedColorScheme");
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
using ElectronNET.API.Entities;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using ElectronNET.API.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API
|
||||
@@ -50,7 +48,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
GenerateIDsForDefinedActions(notificationOptions);
|
||||
|
||||
BridgeConnector.Socket.Emit("createNotification", JObject.FromObject(notificationOptions, _jsonSerializer));
|
||||
BridgeConnector.Socket.Emit("createNotification", notificationOptions);
|
||||
}
|
||||
|
||||
private static void GenerateIDsForDefinedActions(NotificationOptions notificationOptions)
|
||||
@@ -63,7 +61,7 @@ namespace ElectronNET.API
|
||||
isActionDefined = true;
|
||||
|
||||
BridgeConnector.Socket.Off("NotificationEventShow");
|
||||
BridgeConnector.Socket.On("NotificationEventShow", (id) => { _notificationOptions.Single(x => x.ShowID == id.ToString()).OnShow(); });
|
||||
BridgeConnector.Socket.On<JsonElement>("NotificationEventShow", (id) => { _notificationOptions.Single(x => x.ShowID == id.GetString()).OnShow(); });
|
||||
}
|
||||
|
||||
if (notificationOptions.OnClick != null)
|
||||
@@ -72,7 +70,7 @@ namespace ElectronNET.API
|
||||
isActionDefined = true;
|
||||
|
||||
BridgeConnector.Socket.Off("NotificationEventClick");
|
||||
BridgeConnector.Socket.On("NotificationEventClick", (id) => { _notificationOptions.Single(x => x.ClickID == id.ToString()).OnClick(); });
|
||||
BridgeConnector.Socket.On<JsonElement>("NotificationEventClick", (id) => { _notificationOptions.Single(x => x.ClickID == id.GetString()).OnClick(); });
|
||||
}
|
||||
|
||||
if (notificationOptions.OnClose != null)
|
||||
@@ -81,7 +79,7 @@ namespace ElectronNET.API
|
||||
isActionDefined = true;
|
||||
|
||||
BridgeConnector.Socket.Off("NotificationEventClose");
|
||||
BridgeConnector.Socket.On("NotificationEventClose", (id) => { _notificationOptions.Single(x => x.CloseID == id.ToString()).OnClose(); });
|
||||
BridgeConnector.Socket.On<JsonElement>("NotificationEventClose", (id) => { _notificationOptions.Single(x => x.CloseID == id.GetString()).OnClose(); });
|
||||
}
|
||||
|
||||
if (notificationOptions.OnReply != null)
|
||||
@@ -90,10 +88,10 @@ namespace ElectronNET.API
|
||||
isActionDefined = true;
|
||||
|
||||
BridgeConnector.Socket.Off("NotificationEventReply");
|
||||
BridgeConnector.Socket.On("NotificationEventReply", (args) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("NotificationEventReply", (args) =>
|
||||
{
|
||||
var arguments = ((JArray)args).ToObject<string[]>();
|
||||
_notificationOptions.Single(x => x.ReplyID == arguments[0].ToString()).OnReply(arguments[1].ToString());
|
||||
var arguments = args.Deserialize<string[]>(Serialization.ElectronJson.Options);
|
||||
_notificationOptions.Single(x => x.ReplyID == arguments[0]).OnReply(arguments[1]);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -103,10 +101,10 @@ namespace ElectronNET.API
|
||||
isActionDefined = true;
|
||||
|
||||
BridgeConnector.Socket.Off("NotificationEventAction");
|
||||
BridgeConnector.Socket.On("NotificationEventAction", (args) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("NotificationEventAction", (args) =>
|
||||
{
|
||||
var arguments = ((JArray)args).ToObject<string[]>();
|
||||
_notificationOptions.Single(x => x.ReplyID == arguments[0].ToString()).OnAction(arguments[1].ToString());
|
||||
var arguments = JsonSerializer.Deserialize<string[]>(args, Serialization.ElectronJson.Options);
|
||||
_notificationOptions.Single(x => x.ReplyID == arguments[0]).OnAction(arguments[1]);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -124,10 +122,10 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("notificationIsSupportedComplete", (isSupported) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("notificationIsSupportedComplete", (isSupported) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("notificationIsSupportedComplete");
|
||||
taskCompletionSource.SetResult((bool)isSupported);
|
||||
taskCompletionSource.SetResult(isSupported.GetBoolean());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("notificationIsSupported");
|
||||
@@ -135,11 +133,6 @@ namespace ElectronNET.API
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using ElectronNET.Common;
|
||||
using ElectronNET.Common;
|
||||
using System;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using ElectronNET.API.Entities;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
@@ -49,10 +47,10 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
BridgeConnector.Socket.On("process-execPath-Completed", (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("process-execPath-Completed", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("process-execPath-Completed");
|
||||
taskCompletionSource.SetResult(result.ToString());
|
||||
taskCompletionSource.SetResult(result.GetString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("process-execPath");
|
||||
@@ -73,10 +71,10 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string[]>();
|
||||
|
||||
BridgeConnector.Socket.On("process-argv-Completed", (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("process-argv-Completed", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("process-argv-Completed");
|
||||
taskCompletionSource.SetResult(((JArray)result).ToObject<string[]>());
|
||||
taskCompletionSource.SetResult(JsonSerializer.Deserialize<string[]>(result, Serialization.ElectronJson.Options));
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("process-argv");
|
||||
@@ -94,10 +92,10 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
BridgeConnector.Socket.On("process-type-Completed", (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("process-type-Completed", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("process-type-Completed");
|
||||
taskCompletionSource.SetResult(result.ToString());
|
||||
taskCompletionSource.SetResult(result.GetString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("process-type");
|
||||
@@ -116,10 +114,10 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<ProcessVersions>();
|
||||
|
||||
BridgeConnector.Socket.On("process-versions-Completed", (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("process-versions-Completed", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("process-versions-Completed");
|
||||
taskCompletionSource.SetResult(((JObject)result).ToObject<ProcessVersions>());
|
||||
taskCompletionSource.SetResult(JsonSerializer.Deserialize<ProcessVersions>(result, Serialization.ElectronJson.Options));
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("process-versions");
|
||||
@@ -138,10 +136,10 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("process-defaultApp-Completed", (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("process-defaultApp-Completed", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("process-defaultApp-Completed");
|
||||
taskCompletionSource.SetResult(bool.Parse(result.ToString()));
|
||||
taskCompletionSource.SetResult(result.GetBoolean());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("process-defaultApp");
|
||||
@@ -159,10 +157,10 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("process-isMainFrame-Completed", (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("process-isMainFrame-Completed", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("process-isMainFrame-Completed");
|
||||
taskCompletionSource.SetResult(bool.Parse(result.ToString()));
|
||||
taskCompletionSource.SetResult(result.GetBoolean());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("process-isMainFrame");
|
||||
@@ -179,10 +177,10 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
BridgeConnector.Socket.On("process-resourcesPath-Completed", (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("process-resourcesPath-Completed", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("process-resourcesPath-Completed");
|
||||
taskCompletionSource.SetResult(result.ToString());
|
||||
taskCompletionSource.SetResult(result.GetString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("process-resourcesPath");
|
||||
@@ -200,10 +198,10 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<double>();
|
||||
|
||||
BridgeConnector.Socket.On("process-uptime-Completed", (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("process-uptime-Completed", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("process-uptime-Completed");
|
||||
taskCompletionSource.SetResult(double.Parse(result.ToString()));
|
||||
taskCompletionSource.SetResult(result.GetDouble());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("process-uptime");
|
||||
@@ -220,10 +218,10 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<int>();
|
||||
|
||||
BridgeConnector.Socket.On("process-pid-Completed", (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("process-pid-Completed", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("process-pid-Completed");
|
||||
taskCompletionSource.SetResult(int.Parse(result.ToString()));
|
||||
taskCompletionSource.SetResult(result.GetInt32());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("process-pid");
|
||||
@@ -241,10 +239,10 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
BridgeConnector.Socket.On("process-arch-Completed", (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("process-arch-Completed", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("process-arch-Completed");
|
||||
taskCompletionSource.SetResult(result.ToString());
|
||||
taskCompletionSource.SetResult(result.GetString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("process-arch");
|
||||
@@ -261,10 +259,10 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
BridgeConnector.Socket.On("process-platform-Completed", (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("process-platform-Completed", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("process-platform-Completed");
|
||||
taskCompletionSource.SetResult(result.ToString());
|
||||
taskCompletionSource.SetResult(result.GetString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("process-platform");
|
||||
@@ -272,4 +270,4 @@ namespace ElectronNET.API
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
using ElectronNET.API.Entities;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using ElectronNET.API.Entities;
|
||||
using ElectronNET.API.Serialization;
|
||||
using ElectronNET.Common;
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
@@ -18,7 +17,7 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
public event Action<Display> OnDisplayAdded
|
||||
{
|
||||
add => ApiEventManager.AddEvent("screen-display-added", GetHashCode(), _onDisplayAdded, value, (args) => ((JObject)args).ToObject<Display>());
|
||||
add => ApiEventManager.AddEvent("screen-display-added", GetHashCode(), _onDisplayAdded, value, (args) => JsonSerializer.Deserialize(args, Serialization.ElectronJsonContext.Default.Display));
|
||||
remove => ApiEventManager.RemoveEvent("screen-display-added", GetHashCode(), _onDisplayAdded, value);
|
||||
}
|
||||
|
||||
@@ -29,7 +28,7 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
public event Action<Display> OnDisplayRemoved
|
||||
{
|
||||
add => ApiEventManager.AddEvent("screen-display-removed", GetHashCode(), _onDisplayRemoved, value, (args) => ((JObject)args).ToObject<Display>());
|
||||
add => ApiEventManager.AddEvent("screen-display-removed", GetHashCode(), _onDisplayRemoved, value, (args) => JsonSerializer.Deserialize(args, Serialization.ElectronJsonContext.Default.Display));
|
||||
remove => ApiEventManager.RemoveEvent("screen-display-removed", GetHashCode(), _onDisplayRemoved, value);
|
||||
}
|
||||
|
||||
@@ -82,11 +81,11 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<Point>();
|
||||
|
||||
BridgeConnector.Socket.On("screen-getCursorScreenPointCompleted", (point) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("screen-getCursorScreenPointCompleted", (point) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("screen-getCursorScreenPointCompleted");
|
||||
|
||||
taskCompletionSource.SetResult(((JObject)point).ToObject<Point>());
|
||||
taskCompletionSource.SetResult(JsonSerializer.Deserialize<Point>(point, Serialization.ElectronJson.Options));
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("screen-getCursorScreenPoint");
|
||||
@@ -102,11 +101,11 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<int>();
|
||||
|
||||
BridgeConnector.Socket.On("screen-getMenuBarHeightCompleted", (height) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("screen-getMenuBarHeightCompleted", (height) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("screen-getMenuBarHeightCompleted");
|
||||
|
||||
taskCompletionSource.SetResult(int.Parse(height.ToString()));
|
||||
taskCompletionSource.SetResult(height.GetInt32());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("screen-getMenuBarHeight");
|
||||
@@ -122,11 +121,11 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<Display>();
|
||||
|
||||
BridgeConnector.Socket.On("screen-getPrimaryDisplayCompleted", (display) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("screen-getPrimaryDisplayCompleted", (display) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("screen-getPrimaryDisplayCompleted");
|
||||
|
||||
taskCompletionSource.SetResult(((JObject)display).ToObject<Display>());
|
||||
taskCompletionSource.SetResult(display.Deserialize(ElectronJsonContext.Default.Display));
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("screen-getPrimaryDisplay");
|
||||
@@ -142,11 +141,11 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<Display[]>();
|
||||
|
||||
BridgeConnector.Socket.On("screen-getAllDisplaysCompleted", (displays) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("screen-getAllDisplaysCompleted", (displays) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("screen-getAllDisplaysCompleted");
|
||||
|
||||
taskCompletionSource.SetResult(((JArray)displays).ToObject<Display[]>());
|
||||
taskCompletionSource.SetResult(displays.Deserialize<Display[]>(ElectronJson.Options));
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("screen-getAllDisplays");
|
||||
@@ -162,14 +161,14 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<Display>();
|
||||
|
||||
BridgeConnector.Socket.On("screen-getDisplayNearestPointCompleted", (display) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("screen-getDisplayNearestPointCompleted", (display) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("screen-getDisplayNearestPointCompleted");
|
||||
|
||||
taskCompletionSource.SetResult(((JObject)display).ToObject<Display>());
|
||||
taskCompletionSource.SetResult(JsonSerializer.Deserialize(display, Serialization.ElectronJsonContext.Default.Display));
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("screen-getDisplayNearestPoint", JObject.FromObject(point, _jsonSerializer));
|
||||
BridgeConnector.Socket.Emit("screen-getDisplayNearestPoint", point);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
@@ -183,23 +182,18 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<Display>();
|
||||
|
||||
BridgeConnector.Socket.On("screen-getDisplayMatching", (display) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("screen-getDisplayMatching", (display) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("screen-getDisplayMatching");
|
||||
|
||||
taskCompletionSource.SetResult(((JObject)display).ToObject<Display>());
|
||||
taskCompletionSource.SetResult(JsonSerializer.Deserialize(display, Serialization.ElectronJsonContext.Default.Display));
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("screen-getDisplayMatching", JObject.FromObject(rectangle, _jsonSerializer));
|
||||
BridgeConnector.Socket.Emit("screen-getDisplayMatching", rectangle);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using ElectronNET.API.Entities;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using ElectronNET.API.Entities;
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API
|
||||
@@ -59,7 +57,7 @@ namespace ElectronNET.API
|
||||
taskCompletionSource.SetResult(null);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("webContents-session-clearAuthCache", Id, JObject.FromObject(options, _jsonSerializer), guid);
|
||||
BridgeConnector.Socket.Emit("webContents-session-clearAuthCache", Id, options, guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
@@ -159,7 +157,7 @@ namespace ElectronNET.API
|
||||
taskCompletionSource.SetResult(null);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("webContents-session-clearStorageData-options", Id, JObject.FromObject(options, _jsonSerializer), guid);
|
||||
BridgeConnector.Socket.Emit("webContents-session-clearStorageData-options", Id, options, guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
@@ -174,7 +172,7 @@ namespace ElectronNET.API
|
||||
/// <param name="options"></param>
|
||||
public void CreateInterruptedDownload(CreateInterruptedDownloadOptions options)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("webContents-session-createInterruptedDownload", Id, JObject.FromObject(options, _jsonSerializer));
|
||||
BridgeConnector.Socket.Emit("webContents-session-createInterruptedDownload", Id, options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -192,7 +190,7 @@ namespace ElectronNET.API
|
||||
/// <param name="options"></param>
|
||||
public void EnableNetworkEmulation(EnableNetworkEmulationOptions options)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("webContents-session-enableNetworkEmulation", Id, JObject.FromObject(options, _jsonSerializer));
|
||||
BridgeConnector.Socket.Emit("webContents-session-enableNetworkEmulation", Id, options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -213,9 +211,9 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<int[]>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("webContents-session-getBlobData-completed" + guid, (buffer) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("webContents-session-getBlobData-completed" + guid, (buffer) =>
|
||||
{
|
||||
var result = ((JArray)buffer).ToObject<int[]>();
|
||||
var result = JsonSerializer.Deserialize<int[]>(buffer, Serialization.ElectronJson.Options);
|
||||
|
||||
BridgeConnector.Socket.Off("webContents-session-getBlobData-completed" + guid);
|
||||
taskCompletionSource.SetResult(result);
|
||||
@@ -235,10 +233,10 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<int>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("webContents-session-getCacheSize-completed" + guid, (size) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("webContents-session-getCacheSize-completed" + guid, (size) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("webContents-session-getCacheSize-completed" + guid);
|
||||
taskCompletionSource.SetResult((int)size);
|
||||
taskCompletionSource.SetResult(size.GetInt32());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("webContents-session-getCacheSize", Id, guid);
|
||||
@@ -255,9 +253,9 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<string[]>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("webContents-session-getPreloads-completed" + guid, (preloads) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("webContents-session-getPreloads-completed" + guid, (preloads) =>
|
||||
{
|
||||
var result = ((JArray)preloads).ToObject<string[]>();
|
||||
var result = JsonSerializer.Deserialize<string[]>(preloads, Serialization.ElectronJson.Options);
|
||||
BridgeConnector.Socket.Off("webContents-session-getPreloads-completed" + guid);
|
||||
taskCompletionSource.SetResult(result);
|
||||
});
|
||||
@@ -276,10 +274,10 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("webContents-session-getUserAgent-completed" + guid, (userAgent) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("webContents-session-getUserAgent-completed" + guid, (userAgent) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("webContents-session-getUserAgent-completed" + guid);
|
||||
taskCompletionSource.SetResult(userAgent.ToString());
|
||||
taskCompletionSource.SetResult(userAgent.GetString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("webContents-session-getUserAgent", Id, guid);
|
||||
@@ -298,10 +296,10 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("webContents-session-resolveProxy-completed" + guid, (proxy) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("webContents-session-resolveProxy-completed" + guid, (proxy) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("webContents-session-resolveProxy-completed" + guid);
|
||||
taskCompletionSource.SetResult(proxy.ToString());
|
||||
taskCompletionSource.SetResult(proxy.GetString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("webContents-session-resolveProxy", Id, url, guid);
|
||||
@@ -346,7 +344,7 @@ namespace ElectronNET.API
|
||||
taskCompletionSource.SetResult(null);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("webContents-session-setProxy", Id, JObject.FromObject(config, _jsonSerializer), guid);
|
||||
BridgeConnector.Socket.Emit("webContents-session-setProxy", Id, config, guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
@@ -387,10 +385,10 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<ChromeExtensionInfo[]>();
|
||||
|
||||
BridgeConnector.Socket.On("webContents-session-getAllExtensions-completed", (extensionslist) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("webContents-session-getAllExtensions-completed", (extensionslist) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("webContents-session-getAllExtensions-completed");
|
||||
var chromeExtensionInfos = ((JArray)extensionslist).ToObject<ChromeExtensionInfo[]>();
|
||||
var chromeExtensionInfos = JsonSerializer.Deserialize<ChromeExtensionInfo[]>(extensionslist, Serialization.ElectronJson.Options);
|
||||
|
||||
taskCompletionSource.SetResult(chromeExtensionInfos);
|
||||
});
|
||||
@@ -441,11 +439,11 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<Extension>();
|
||||
|
||||
BridgeConnector.Socket.On("webContents-session-loadExtension-completed", (extension) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("webContents-session-loadExtension-completed", (extension) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("webContents-session-loadExtension-completed");
|
||||
|
||||
taskCompletionSource.SetResult(((JObject)extension).ToObject<Extension>());
|
||||
taskCompletionSource.SetResult(JsonSerializer.Deserialize<Extension>(extension, Serialization.ElectronJson.Options));
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("webContents-session-loadExtension", Id, path, allowFileAccess);
|
||||
@@ -453,11 +451,6 @@ namespace ElectronNET.API
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using ElectronNET.API.Entities;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using ElectronNET.API.Entities;
|
||||
using ElectronNET.API.Extensions;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
@@ -62,11 +60,11 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
BridgeConnector.Socket.On("shell-openPathCompleted", (errorMessage) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("shell-openPathCompleted", (errorMessage) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("shell-openPathCompleted");
|
||||
|
||||
taskCompletionSource.SetResult((string)errorMessage);
|
||||
taskCompletionSource.SetResult(errorMessage.GetString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("shell-openPath", path);
|
||||
@@ -96,11 +94,11 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
BridgeConnector.Socket.On("shell-openExternalCompleted", (error) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("shell-openExternalCompleted", (error) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("shell-openExternalCompleted");
|
||||
|
||||
taskCompletionSource.SetResult((string)error);
|
||||
taskCompletionSource.SetResult(error.GetString());
|
||||
});
|
||||
|
||||
if (options == null)
|
||||
@@ -109,7 +107,7 @@ namespace ElectronNET.API
|
||||
}
|
||||
else
|
||||
{
|
||||
BridgeConnector.Socket.Emit("shell-openExternal", url, JObject.FromObject(options, _jsonSerializer));
|
||||
BridgeConnector.Socket.Emit("shell-openExternal", url, options);
|
||||
}
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
@@ -124,11 +122,11 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("shell-trashItem-completed", (success) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("shell-trashItem-completed", (success) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("shell-trashItem-completed");
|
||||
|
||||
taskCompletionSource.SetResult((bool)success);
|
||||
taskCompletionSource.SetResult(success.GetBoolean());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("shell-trashItem", fullPath);
|
||||
@@ -155,14 +153,14 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("shell-writeShortcutLinkCompleted", (success) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("shell-writeShortcutLinkCompleted", (success) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("shell-writeShortcutLinkCompleted");
|
||||
|
||||
taskCompletionSource.SetResult((bool)success);
|
||||
taskCompletionSource.SetResult(success.GetBoolean());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("shell-writeShortcutLink", shortcutPath, operation.GetDescription(), JObject.FromObject(options, _jsonSerializer));
|
||||
BridgeConnector.Socket.Emit("shell-writeShortcutLink", shortcutPath, operation.GetDescription(), options);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
@@ -177,12 +175,11 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<ShortcutDetails>();
|
||||
|
||||
BridgeConnector.Socket.On("shell-readShortcutLinkCompleted", (shortcutDetails) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("shell-readShortcutLinkCompleted", (shortcutDetails) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("shell-readShortcutLinkCompleted");
|
||||
|
||||
var shortcutObject = shortcutDetails as JObject;
|
||||
var details = shortcutObject?.ToObject<ShortcutDetails>();
|
||||
var details = JsonSerializer.Deserialize<ShortcutDetails>(shortcutDetails, Serialization.ElectronJson.Options);
|
||||
|
||||
taskCompletionSource.SetResult(details);
|
||||
});
|
||||
@@ -192,11 +189,6 @@ namespace ElectronNET.API
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
private readonly JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
using ElectronNET.API.Entities;
|
||||
using ElectronNET.API.Entities;
|
||||
using ElectronNET.API.Extensions;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using ElectronNET.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using ElectronNET.Common;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
@@ -140,7 +137,7 @@ namespace ElectronNET.API
|
||||
public async Task Show(string image, MenuItem[] menuItems)
|
||||
{
|
||||
menuItems.AddMenuItemsId();
|
||||
await BridgeConnector.Socket.Emit("create-tray", image, JArray.FromObject(menuItems, this._jsonSerializer)).ConfigureAwait(false);
|
||||
await BridgeConnector.Socket.Emit("create-tray", image, menuItems).ConfigureAwait(false);
|
||||
_items.Clear();
|
||||
_items.AddRange(menuItems);
|
||||
|
||||
@@ -212,7 +209,7 @@ namespace ElectronNET.API
|
||||
/// <param name="options"></param>
|
||||
public async Task DisplayBalloon(DisplayBalloonOptions options)
|
||||
{
|
||||
await BridgeConnector.Socket.Emit("tray-displayBalloon", JObject.FromObject(options, this._jsonSerializer)).ConfigureAwait(false);
|
||||
await BridgeConnector.Socket.Emit("tray-displayBalloon", options).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -235,11 +232,7 @@ namespace ElectronNET.API
|
||||
return await taskCompletionSource.Task.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private readonly JsonSerializer _jsonSerializer = new()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
|
||||
|
||||
private const string ModuleName = "tray";
|
||||
|
||||
@@ -275,4 +268,4 @@ namespace ElectronNET.API
|
||||
public async Task Once<T>(string eventName, Action<T> action)
|
||||
=> await Events.Instance.Once(ModuleName, eventName, action).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
using ElectronNET.API.Entities;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using ElectronNET.API.Entities;
|
||||
using ElectronNET.API.Serialization;
|
||||
using ElectronNET.Common;
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
@@ -33,7 +32,7 @@ public class WebContents
|
||||
/// </summary>
|
||||
public event Action<bool> OnCrashed
|
||||
{
|
||||
add => ApiEventManager.AddEvent("webContents-crashed", Id, _crashed, value, (args) => (bool)args);
|
||||
add => ApiEventManager.AddEvent("webContents-crashed", Id, _crashed, value, (args) => args.GetBoolean());
|
||||
remove => ApiEventManager.RemoveEvent("webContents-crashed", Id, _crashed, value);
|
||||
}
|
||||
|
||||
@@ -102,7 +101,7 @@ public class WebContents
|
||||
/// </summary>
|
||||
public event Action<OnDidFailLoadInfo> OnDidFailLoad
|
||||
{
|
||||
add => ApiEventManager.AddEvent("webContents-didFailLoad", Id, _didFailLoad, value, (args) => ((JObject)args).ToObject<OnDidFailLoadInfo>());
|
||||
add => ApiEventManager.AddEvent("webContents-didFailLoad", Id, _didFailLoad, value, (args) => JsonSerializer.Deserialize<OnDidFailLoadInfo>(args, ElectronJson.Options));
|
||||
remove => ApiEventManager.RemoveEvent("webContents-didFailLoad", Id, _didFailLoad, value);
|
||||
}
|
||||
|
||||
@@ -113,7 +112,7 @@ public class WebContents
|
||||
/// </summary>
|
||||
public event Action<InputEvent> InputEvent
|
||||
{
|
||||
add => ApiEventManager.AddEvent("webContents-input-event", Id, _inputEvent, value, (args) => ((JObject)args).ToObject<InputEvent>());
|
||||
add => ApiEventManager.AddEvent("webContents-input-event", Id, _inputEvent, value, (args) => JsonSerializer.Deserialize<InputEvent>(args, ElectronJson.Options));
|
||||
remove => ApiEventManager.RemoveEvent("webContents-input-event", Id, _inputEvent, value);
|
||||
}
|
||||
|
||||
@@ -150,7 +149,7 @@ public class WebContents
|
||||
/// <param name="openDevToolsOptions"></param>
|
||||
public void OpenDevTools(OpenDevToolsOptions openDevToolsOptions)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("webContentsOpenDevTools", Id, JObject.FromObject(openDevToolsOptions, _jsonSerializer));
|
||||
BridgeConnector.Socket.Emit("webContentsOpenDevTools", Id, openDevToolsOptions);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -161,11 +160,11 @@ public class WebContents
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<PrinterInfo[]>();
|
||||
|
||||
BridgeConnector.Socket.On("webContents-getPrinters-completed", (printers) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("webContents-getPrinters-completed", (printers) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("webContents-getPrinters-completed");
|
||||
|
||||
taskCompletionSource.SetResult(((Newtonsoft.Json.Linq.JArray)printers).ToObject<PrinterInfo[]>());
|
||||
taskCompletionSource.SetResult(JsonSerializer.Deserialize<PrinterInfo[]>(printers, ElectronJson.Options));
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("webContents-getPrinters", Id);
|
||||
@@ -182,10 +181,10 @@ public class WebContents
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("webContents-print-completed", (success) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("webContents-print-completed", (success) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("webContents-print-completed");
|
||||
taskCompletionSource.SetResult((bool)success);
|
||||
taskCompletionSource.SetResult(success.GetBoolean());
|
||||
});
|
||||
|
||||
if (options == null)
|
||||
@@ -194,7 +193,7 @@ public class WebContents
|
||||
}
|
||||
else
|
||||
{
|
||||
BridgeConnector.Socket.Emit("webContents-print", Id, JObject.FromObject(options, _jsonSerializer));
|
||||
BridgeConnector.Socket.Emit("webContents-print", Id, options);
|
||||
}
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
@@ -213,10 +212,10 @@ public class WebContents
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("webContents-printToPDF-completed", (success) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("webContents-printToPDF-completed", (success) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("webContents-printToPDF-completed");
|
||||
taskCompletionSource.SetResult((bool)success);
|
||||
taskCompletionSource.SetResult(success.GetBoolean());
|
||||
});
|
||||
|
||||
if (options == null)
|
||||
@@ -225,7 +224,7 @@ public class WebContents
|
||||
}
|
||||
else
|
||||
{
|
||||
BridgeConnector.Socket.Emit("webContents-printToPDF", Id, JObject.FromObject(options, _jsonSerializer), path);
|
||||
BridgeConnector.Socket.Emit("webContents-printToPDF", Id, options, path);
|
||||
}
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
@@ -247,14 +246,14 @@ public class WebContents
|
||||
/// Code execution will be suspended until web page stop loading.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public Task<object> ExecuteJavaScriptAsync(string code, bool userGesture = false)
|
||||
public Task<T> ExecuteJavaScriptAsync<T>(string code, bool userGesture = false)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<object>();
|
||||
var taskCompletionSource = new TaskCompletionSource<T>();
|
||||
|
||||
BridgeConnector.Socket.On("webContents-executeJavaScript-completed", (result) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("webContents-executeJavaScript-completed", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("webContents-executeJavaScript-completed");
|
||||
taskCompletionSource.SetResult(result);
|
||||
taskCompletionSource.SetResult(result.Deserialize<T>(ElectronJson.Options));
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("webContents-executeJavaScript", Id, code, userGesture);
|
||||
@@ -272,10 +271,10 @@ public class WebContents
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
var eventString = "webContents-getUrl" + Id;
|
||||
BridgeConnector.Socket.On(eventString, (url) =>
|
||||
BridgeConnector.Socket.On<JsonElement>(eventString, (url) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off(eventString);
|
||||
taskCompletionSource.SetResult((string)url);
|
||||
taskCompletionSource.SetResult(url.GetString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("webContents-getUrl", Id);
|
||||
@@ -324,13 +323,13 @@ public class WebContents
|
||||
taskCompletionSource.SetResult(null);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.On("webContents-loadURL-error" + Id, (error) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("webContents-loadURL-error" + Id, (error) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("webContents-loadURL-error" + Id);
|
||||
taskCompletionSource.SetException(new InvalidOperationException(error.ToString()));
|
||||
taskCompletionSource.SetException(new InvalidOperationException(error.GetString()));
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("webContents-loadURL", Id, url, JObject.FromObject(options, _jsonSerializer));
|
||||
BridgeConnector.Socket.Emit("webContents-loadURL", Id, url, options);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
@@ -347,10 +346,5 @@ public class WebContents
|
||||
BridgeConnector.Socket.Emit("webContents-insertCSS", Id, isBrowserWindow, path);
|
||||
}
|
||||
|
||||
private readonly JsonSerializer _jsonSerializer = new()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
@@ -33,18 +32,17 @@ namespace ElectronNET.API.Entities
|
||||
{
|
||||
if (_onBeforeRequest == null)
|
||||
{
|
||||
BridgeConnector.Socket.On($"webContents-session-webRequest-onBeforeRequest{Id}",
|
||||
BridgeConnector.Socket.On<System.Text.Json.JsonElement>($"webContents-session-webRequest-onBeforeRequest{Id}",
|
||||
(args) =>
|
||||
{
|
||||
////var details = ((JObject)args[0]).ToObject<OnBeforeRequestDetails>();
|
||||
////var callback = args.Length > 1 ? (Action<object>)((response) => { BridgeConnector.Socket.Emit($"webContents-session-webRequest-onBeforeRequest-response{Id}", response); }) : null;
|
||||
var details = ((JObject)args).ToObject<OnBeforeRequestDetails>();
|
||||
//// var details0 = args[0].Deserialize<OnBeforeRequestDetails>(ElectronNET.API.Serialization.ElectronJson.Options);
|
||||
var details = System.Text.Json.JsonSerializer.Deserialize<OnBeforeRequestDetails>(args, Serialization.ElectronJson.Options);
|
||||
var callback = (Action<object>)((response) => { BridgeConnector.Socket.Emit($"webContents-session-webRequest-onBeforeRequest-response{Id}", response); });
|
||||
|
||||
_onBeforeRequest?.Invoke(details, callback);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-webContents-session-webRequest-onBeforeRequest", Id, JObject.FromObject(filter));
|
||||
BridgeConnector.Socket.Emit("register-webContents-session-webRequest-onBeforeRequest", Id, filter);
|
||||
}
|
||||
|
||||
_onBeforeRequest += listener;
|
||||
@@ -59,4 +57,4 @@ namespace ElectronNET.API.Entities
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
using ElectronNET.API.Entities;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using ElectronNET.API.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API
|
||||
@@ -100,11 +97,11 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<BrowserWindow>();
|
||||
|
||||
BridgeConnector.Socket.On("BrowserWindowCreated", (id) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("BrowserWindowCreated", (id) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("BrowserWindowCreated");
|
||||
|
||||
var browserWindowId = int.Parse(id.ToString()!);
|
||||
var browserWindowId = id.GetInt32();
|
||||
|
||||
var browserWindow = new BrowserWindow(browserWindowId);
|
||||
_browserWindows.Add(browserWindow);
|
||||
@@ -112,11 +109,11 @@ namespace ElectronNET.API
|
||||
taskCompletionSource.SetResult(browserWindow);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.On<object>("BrowserWindowClosed", (ids) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("BrowserWindowClosed", (ids) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("BrowserWindowClosed");
|
||||
|
||||
var browserWindowIds = ((JArray)ids).ToObject<int[]>();
|
||||
var browserWindowIds = ids.Deserialize<int[]>(Serialization.ElectronJson.Options);
|
||||
|
||||
for (int index = 0; index < _browserWindows.Count; index++)
|
||||
{
|
||||
@@ -127,7 +124,7 @@ namespace ElectronNET.API
|
||||
}
|
||||
});
|
||||
|
||||
if (loadUrl.ToUpper() == "HTTP://LOCALHOST" && ElectronNetRuntime.AspNetWebPort.HasValue)
|
||||
if (loadUrl.Equals("http://localhost", StringComparison.OrdinalIgnoreCase) && ElectronNetRuntime.AspNetWebPort.HasValue)
|
||||
{
|
||||
loadUrl = $"{loadUrl}:{ElectronNetRuntime.AspNetWebPort}";
|
||||
}
|
||||
@@ -145,7 +142,7 @@ namespace ElectronNET.API
|
||||
options.X = 0;
|
||||
options.Y = 0;
|
||||
|
||||
await BridgeConnector.Socket.Emit("createBrowserWindow", JObject.FromObject(options, this._jsonSerializer), loadUrl).ConfigureAwait(false);
|
||||
await BridgeConnector.Socket.Emit("createBrowserWindow", options, loadUrl).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -156,7 +153,7 @@ namespace ElectronNET.API
|
||||
options.X -= 7;
|
||||
}
|
||||
|
||||
await BridgeConnector.Socket.Emit("createBrowserWindow", JObject.FromObject(options, this._jsonSerializer), loadUrl).ConfigureAwait(false);
|
||||
await BridgeConnector.Socket.Emit("createBrowserWindow", options, loadUrl).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
return await taskCompletionSource.Task.ConfigureAwait(false);
|
||||
@@ -189,32 +186,22 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<BrowserView>();
|
||||
|
||||
BridgeConnector.Socket.On("BrowserViewCreated", (id) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("BrowserViewCreated", (id) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("BrowserViewCreated");
|
||||
|
||||
string browserViewId = id.ToString();
|
||||
BrowserView browserView = new BrowserView(int.Parse(browserViewId));
|
||||
var browserViewId = id.GetInt32();
|
||||
BrowserView browserView = new(browserViewId);
|
||||
|
||||
_browserViews.Add(browserView);
|
||||
|
||||
taskCompletionSource.SetResult(browserView);
|
||||
});
|
||||
|
||||
var ownjsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
await BridgeConnector.Socket.Emit("createBrowserView", JObject.FromObject(options, ownjsonSerializer)).ConfigureAwait(false);
|
||||
await BridgeConnector.Socket.Emit("createBrowserView", options).ConfigureAwait(false);
|
||||
|
||||
return await taskCompletionSource.Task.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private readonly JsonSerializer _jsonSerializer = new()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user