diff --git a/src/ElectronNET.API/API/ApiBase.cs b/src/ElectronNET.API/API/ApiBase.cs
index 13285cac..83adcfb6 100644
--- a/src/ElectronNET.API/API/ApiBase.cs
+++ b/src/ElectronNET.API/API/ApiBase.cs
@@ -1,11 +1,13 @@
namespace ElectronNET.API
{
+ using ElectronNET.API.Serialization;
+ 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
{
@@ -156,8 +158,19 @@ public PropertyGetter(ApiBase apiBase, string callerName, int timeoutMs)
lock (this)
{
- this.tcs?.SetResult(result);
- this.tcs = null;
+ try
+ {
+ var value = result;
+ this.tcs?.SetResult(value);
+ }
+ catch (Exception ex)
+ {
+ this.tcs?.TrySetException(ex);
+ }
+ finally
+ {
+ this.tcs = null;
+ }
}
});
@@ -170,7 +183,7 @@ public PropertyGetter(ApiBase apiBase, string callerName, int timeoutMs)
BridgeConnector.Socket.Emit(messageName);
}
- System.Threading.Tasks.Task.Delay(ApiBase.PropertyTimeout).ContinueWith(_ =>
+ System.Threading.Tasks.Task.Delay(PropertyTimeout).ContinueWith(_ =>
{
if (this.tcs != null)
{
diff --git a/src/ElectronNET.API/API/App.cs b/src/ElectronNET.API/API/App.cs
index 4739d0a6..7a9a6652 100644
--- a/src/ElectronNET.API/API/App.cs
+++ b/src/ElectronNET.API/API/App.cs
@@ -1,13 +1,12 @@
-using ElectronNET.API.Entities;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
-using Newtonsoft.Json.Serialization;
+using ElectronNET.API.Entities;
+using ElectronNET.API.Extensions;
+using ElectronNET.API.Serialization;
+using ElectronNET.Common;
using System;
using System.Runtime.InteropServices;
+using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
-using ElectronNET.API.Extensions;
-using ElectronNET.Common;
// ReSharper disable InconsistentNaming
@@ -271,7 +270,7 @@ public event Action WebContentsCreated
/// when Chrome's accessibility support is enabled, otherwise.
public event Action 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 +413,7 @@ internal static App Instance
private static App _app;
private static object _syncRoot = new object();
- private readonly JsonSerializer _jsonSerializer = new JsonSerializer()
- {
- ContractResolver = new CamelCasePropertyNamesContractResolver()
- };
+
///
/// Try to close all windows. The event will be emitted first. If all windows are successfully
@@ -475,7 +471,7 @@ public void Relaunch()
/// Options for the relaunch.
public void Relaunch(RelaunchOptions relaunchOptions)
{
- this.CallMethod1(JObject.FromObject(relaunchOptions, _jsonSerializer));
+ this.CallMethod1(relaunchOptions);
}
///
@@ -495,7 +491,7 @@ public void Focus()
///
public void Focus(FocusOptions focusOptions)
{
- this.CallMethod1(JObject.FromObject(focusOptions, _jsonSerializer));
+ this.CallMethod1(focusOptions);
}
///
@@ -551,11 +547,11 @@ public async Task GetPathAsync(PathName pathName, CancellationToken canc
var taskCompletionSource = new TaskCompletionSource();
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
{
- BridgeConnector.Socket.On("appGetPathCompleted", (path) =>
+ BridgeConnector.Socket.On("appGetPathCompleted", (path) =>
{
BridgeConnector.Socket.Off("appGetPathCompleted");
- taskCompletionSource.SetResult(path.ToString());
+ taskCompletionSource.SetResult(path);
});
BridgeConnector.Socket.Emit("appGetPath", pathName.GetDescription());
@@ -720,10 +716,10 @@ public async Task SetAsDefaultProtocolClientAsync(string protocol, string
var taskCompletionSource = new TaskCompletionSource();
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
{
- BridgeConnector.Socket.On("appSetAsDefaultProtocolClientCompleted", (success) =>
+ BridgeConnector.Socket.On("appSetAsDefaultProtocolClientCompleted", (success) =>
{
BridgeConnector.Socket.Off("appSetAsDefaultProtocolClientCompleted");
- taskCompletionSource.SetResult((bool)success);
+ taskCompletionSource.SetResult(success);
});
BridgeConnector.Socket.Emit("appSetAsDefaultProtocolClient", protocol, path, args);
@@ -774,10 +770,10 @@ public async Task RemoveAsDefaultProtocolClientAsync(string protocol, stri
var taskCompletionSource = new TaskCompletionSource();
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
{
- BridgeConnector.Socket.On("appRemoveAsDefaultProtocolClientCompleted", (success) =>
+ BridgeConnector.Socket.On("appRemoveAsDefaultProtocolClientCompleted", (success) =>
{
BridgeConnector.Socket.Off("appRemoveAsDefaultProtocolClientCompleted");
- taskCompletionSource.SetResult((bool)success);
+ taskCompletionSource.SetResult(success);
});
BridgeConnector.Socket.Emit("appRemoveAsDefaultProtocolClient", protocol, path, args);
@@ -846,10 +842,10 @@ public async Task IsDefaultProtocolClientAsync(string protocol, string pat
var taskCompletionSource = new TaskCompletionSource();
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
{
- BridgeConnector.Socket.On("appIsDefaultProtocolClientCompleted", (success) =>
+ BridgeConnector.Socket.On("appIsDefaultProtocolClientCompleted", (success) =>
{
BridgeConnector.Socket.Off("appIsDefaultProtocolClientCompleted");
- taskCompletionSource.SetResult((bool)success);
+ taskCompletionSource.SetResult(success);
});
BridgeConnector.Socket.Emit("appIsDefaultProtocolClient", protocol, path, args);
@@ -874,13 +870,13 @@ public async Task SetUserTasksAsync(UserTask[] userTasks, CancellationToke
var taskCompletionSource = new TaskCompletionSource();
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
{
- BridgeConnector.Socket.On("appSetUserTasksCompleted", (success) =>
+ BridgeConnector.Socket.On("appSetUserTasksCompleted", (success) =>
{
BridgeConnector.Socket.Off("appSetUserTasksCompleted");
- taskCompletionSource.SetResult((bool)success);
+ taskCompletionSource.SetResult(success);
});
- BridgeConnector.Socket.Emit("appSetUserTasks", JArray.FromObject(userTasks, _jsonSerializer));
+ BridgeConnector.Socket.Emit("appSetUserTasks", userTasks);
return await taskCompletionSource.Task
.ConfigureAwait(false);
@@ -916,7 +912,7 @@ public async Task GetJumpListSettingsAsync(CancellationToken c
/// Array of objects.
public void SetJumpList(JumpListCategory[] categories)
{
- this.CallMethod1(JArray.FromObject(categories, _jsonSerializer));
+ this.CallMethod1(categories);
}
///
@@ -947,19 +943,21 @@ public async Task RequestSingleInstanceLockAsync(Action
var taskCompletionSource = new TaskCompletionSource();
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
{
- BridgeConnector.Socket.On("appRequestSingleInstanceLockCompleted", (success) =>
+ BridgeConnector.Socket.On("appRequestSingleInstanceLockCompleted", (success) =>
{
BridgeConnector.Socket.Off("appRequestSingleInstanceLockCompleted");
- taskCompletionSource.SetResult((bool)success);
+ taskCompletionSource.SetResult(success);
});
BridgeConnector.Socket.Off("secondInstance");
- BridgeConnector.Socket.On("secondInstance", (result) =>
+ BridgeConnector.Socket.On("secondInstance", (result) =>
{
- JArray results = (JArray)result;
- string[] args = results.First.ToObject();
- string workingDirectory = results.Last.ToObject();
-
+ var arr = result.EnumerateArray();
+ var e = arr.GetEnumerator();
+ e.MoveNext();
+ var args = e.Current.Deserialize(JsonSerializerOptions.Default);
+ e.MoveNext();
+ var workingDirectory = e.Current.GetString();
newInstanceOpened(args, workingDirectory);
});
@@ -1071,13 +1069,13 @@ public async Task ImportCertificateAsync(ImportCertificateOptions options,
var taskCompletionSource = new TaskCompletionSource();
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
{
- BridgeConnector.Socket.On("appImportCertificateCompleted", (result) =>
+ BridgeConnector.Socket.On("appImportCertificateCompleted", (result) =>
{
BridgeConnector.Socket.Off("appImportCertificateCompleted");
- taskCompletionSource.SetResult((int)result);
+ taskCompletionSource.SetResult(result);
});
- BridgeConnector.Socket.Emit("appImportCertificate", JObject.FromObject(options, _jsonSerializer));
+ BridgeConnector.Socket.Emit("appImportCertificate", options);
return await taskCompletionSource.Task
.ConfigureAwait(false);
@@ -1127,10 +1125,10 @@ public async Task SetBadgeCountAsync(int count, CancellationToken cancella
var taskCompletionSource = new TaskCompletionSource();
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
{
- BridgeConnector.Socket.On("appSetBadgeCountCompleted", (success) =>
+ BridgeConnector.Socket.On("appSetBadgeCountCompleted", (success) =>
{
BridgeConnector.Socket.Off("appSetBadgeCountCompleted");
- taskCompletionSource.SetResult((bool)success);
+ taskCompletionSource.SetResult(success);
});
BridgeConnector.Socket.Emit("appSetBadgeCount", count);
@@ -1187,12 +1185,9 @@ public async Task GetLoginItemSettingsAsync(LoginItemSettings
var taskCompletionSource = new TaskCompletionSource();
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
{
- BridgeConnector.Socket.On("appGetLoginItemSettingsCompleted", (loginItemSettings) =>
+ BridgeConnector.Socket.On("appGetLoginItemSettingsCompleted", (result) =>
{
BridgeConnector.Socket.Off("appGetLoginItemSettingsCompleted");
-
- var result = ((JObject)loginItemSettings).ToObject();
-
taskCompletionSource.SetResult(result);
});
@@ -1202,7 +1197,7 @@ public async Task GetLoginItemSettingsAsync(LoginItemSettings
}
else
{
- BridgeConnector.Socket.Emit("appGetLoginItemSettings", JObject.FromObject(options, _jsonSerializer));
+ BridgeConnector.Socket.Emit("appGetLoginItemSettings", options);
}
return await taskCompletionSource.Task
@@ -1218,7 +1213,7 @@ public async Task GetLoginItemSettingsAsync(LoginItemSettings
///
public void SetLoginItemSettings(LoginSettings loginSettings)
{
- this.CallMethod1(JObject.FromObject(loginSettings, _jsonSerializer));
+ this.CallMethod1(loginSettings);
}
///
@@ -1270,7 +1265,7 @@ public void ShowAboutPanel()
/// About panel options.
public void SetAboutPanelOptions(AboutPanelOptions options)
{
- this.CallMethod1(JObject.FromObject(options, _jsonSerializer));
+ this.CallMethod1(options);
}
///
@@ -1306,14 +1301,14 @@ public Task UserAgentFallbackAsync
{
get
{
- return Task.Run(() =>
+ return Task.Run(() =>
{
var taskCompletionSource = new TaskCompletionSource();
- BridgeConnector.Socket.On("appGetUserAgentFallbackCompleted", (result) =>
+ BridgeConnector.Socket.On("appGetUserAgentFallbackCompleted", (result) =>
{
BridgeConnector.Socket.Off("appGetUserAgentFallbackCompleted");
- taskCompletionSource.SetResult((string)result);
+ taskCompletionSource.SetResult(result);
});
BridgeConnector.Socket.Emit("appGetUserAgentFallback");
@@ -1364,4 +1359,4 @@ public void Once(string eventName, Action action)
public async Task Once(string eventName, Action
public event Action OnUpdateAvailable
{
- add => ApiEventManager.AddEvent("autoUpdater-update-available", GetHashCode(), _updateAvailable, value, (args) => JObject.Parse(args.ToString()).ToObject());
+ add => ApiEventManager.AddEvent("autoUpdater-update-available", GetHashCode(), _updateAvailable, value, (args) => args.Deserialize(ElectronJsonContext.Default.UpdateInfo));
remove => ApiEventManager.RemoveEvent("autoUpdater-update-available", GetHashCode(), _updateAvailable, value);
}
@@ -322,7 +319,7 @@ public event Action OnUpdateAvailable
///
public event Action OnUpdateNotAvailable
{
- add => ApiEventManager.AddEvent("autoUpdater-update-not-available", GetHashCode(), _updateNotAvailable, value, (args) => JObject.Parse(args.ToString()).ToObject());
+ add => ApiEventManager.AddEvent("autoUpdater-update-not-available", GetHashCode(), _updateNotAvailable, value, (args) => args.Deserialize(ElectronJsonContext.Default.UpdateInfo));
remove => ApiEventManager.RemoveEvent("autoUpdater-update-not-available", GetHashCode(), _updateNotAvailable, value);
}
@@ -333,7 +330,7 @@ public event Action OnUpdateNotAvailable
///
public event Action OnDownloadProgress
{
- add => ApiEventManager.AddEvent("autoUpdater-download-progress", GetHashCode(), _downloadProgress, value, (args) => JObject.Parse(args.ToString()).ToObject());
+ add => ApiEventManager.AddEvent("autoUpdater-download-progress", GetHashCode(), _downloadProgress, value, (args) => args.Deserialize(ElectronJsonContext.Default.ProgressInfo));
remove => ApiEventManager.RemoveEvent("autoUpdater-download-progress", GetHashCode(), _downloadProgress, value);
}
@@ -344,7 +341,7 @@ public event Action OnDownloadProgress
///
public event Action OnUpdateDownloaded
{
- add => ApiEventManager.AddEvent("autoUpdater-update-downloaded", GetHashCode(), _updateDownloaded, value, (args) => JObject.Parse(args.ToString()).ToObject());
+ add => ApiEventManager.AddEvent("autoUpdater-update-downloaded", GetHashCode(), _updateDownloaded, value, (args) => args.Deserialize(ElectronJsonContext.Default.UpdateInfo));
remove => ApiEventManager.RemoveEvent("autoUpdater-update-downloaded", GetHashCode(), _updateDownloaded, value);
}
@@ -385,26 +382,25 @@ public Task CheckForUpdatesAsync()
var taskCompletionSource = new TaskCompletionSource();
string guid = Guid.NewGuid().ToString();
- BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesComplete" + guid, (updateCheckResult) =>
+ BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesComplete" + guid, (result) =>
{
try
{
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesComplete" + guid);
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesError" + guid);
- taskCompletionSource.SetResult(JObject.Parse(updateCheckResult.ToString()).ToObject());
+ taskCompletionSource.SetResult(result);
}
catch (Exception ex)
{
taskCompletionSource.SetException(ex);
}
});
- BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesError" + guid, (error) =>
+ BridgeConnector.Socket.On("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);
+ if (!string.IsNullOrEmpty(result)) message = result;
taskCompletionSource.SetException(new Exception(message));
});
@@ -424,29 +420,25 @@ public Task CheckForUpdatesAndNotifyAsync()
var taskCompletionSource = new TaskCompletionSource();
string guid = Guid.NewGuid().ToString();
- BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesAndNotifyComplete" + guid, (updateCheckResult) =>
+ BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesAndNotifyComplete" + guid, (result) =>
{
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());
+ taskCompletionSource.SetResult(result);
}
catch (Exception ex)
{
taskCompletionSource.SetException(ex);
}
});
- BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesAndNotifyError" + guid, (error) =>
+ BridgeConnector.Socket.On("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);
+ if (!string.IsNullOrEmpty(result)) message = result;
taskCompletionSource.SetException(new Exception(message));
});
@@ -478,10 +470,10 @@ public Task DownloadUpdateAsync()
var taskCompletionSource = new TaskCompletionSource();
string guid = Guid.NewGuid().ToString();
- BridgeConnector.Socket.On("autoUpdaterDownloadUpdateComplete" + guid, (downloadedPath) =>
+ BridgeConnector.Socket.On("autoUpdaterDownloadUpdateComplete" + guid, (downloadedPath) =>
{
BridgeConnector.Socket.Off("autoUpdaterDownloadUpdateComplete" + guid);
- taskCompletionSource.SetResult(downloadedPath.ToString());
+ taskCompletionSource.SetResult(downloadedPath);
});
BridgeConnector.Socket.Emit("autoUpdaterDownloadUpdate", guid);
@@ -498,10 +490,10 @@ public Task GetFeedURLAsync()
var taskCompletionSource = new TaskCompletionSource();
string guid = Guid.NewGuid().ToString();
- BridgeConnector.Socket.On("autoUpdaterGetFeedURLComplete" + guid, (downloadedPath) =>
+ BridgeConnector.Socket.On("autoUpdaterGetFeedURLComplete" + guid, (downloadedPath) =>
{
BridgeConnector.Socket.Off("autoUpdaterGetFeedURLComplete" + guid);
- taskCompletionSource.SetResult(downloadedPath.ToString());
+ taskCompletionSource.SetResult(downloadedPath);
});
BridgeConnector.Socket.Emit("autoUpdaterGetFeedURL", guid);
@@ -509,9 +501,8 @@ public Task GetFeedURLAsync()
return taskCompletionSource.Task;
}
- private readonly JsonSerializer _jsonSerializer = new JsonSerializer()
- {
- ContractResolver = new CamelCasePropertyNamesContractResolver()
- };
+
}
-}
\ No newline at end of file
+}
+
+
diff --git a/src/ElectronNET.API/API/BrowserView.cs b/src/ElectronNET.API/API/BrowserView.cs
index 50814f2c..2a4aa0cc 100644
--- a/src/ElectronNET.API/API/BrowserView.cs
+++ b/src/ElectronNET.API/API/BrowserView.cs
@@ -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
{
///
- /// 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.
///
public class BrowserView
@@ -16,9 +15,6 @@ public class BrowserView
///
/// Gets the identifier.
///
- ///
- /// The identifier.
- ///
public int Id { get; internal set; }
///
@@ -28,7 +24,6 @@ public class BrowserView
///
/// Resizes and moves the view to the supplied bounds relative to the window.
- ///
/// (experimental)
///
public Rectangle Bounds
@@ -52,7 +47,7 @@ public Rectangle Bounds
}
set
{
- BridgeConnector.Socket.Emit("browserView-setBounds", Id, JObject.FromObject(value, _jsonSerializer));
+ BridgeConnector.Socket.Emit("browserView-setBounds", Id, value);
}
}
@@ -74,12 +69,11 @@ internal BrowserView(int id)
///
public void SetAutoResize(AutoResizeOptions options)
{
- BridgeConnector.Socket.Emit("browserView-setAutoResize", Id, JObject.FromObject(options, _jsonSerializer));
+ BridgeConnector.Socket.Emit("browserView-setAutoResize", Id, options);
}
///
/// Color in #aarrggbb or #argb form. The alpha channel is optional.
- ///
/// (experimental)
///
/// Color in #aarrggbb or #argb form. The alpha channel is optional.
@@ -87,11 +81,6 @@ public void SetBackgroundColor(string color)
{
BridgeConnector.Socket.Emit("browserView-setBackgroundColor", Id, color);
}
-
- private JsonSerializer _jsonSerializer = new JsonSerializer()
- {
- ContractResolver = new CamelCasePropertyNamesContractResolver(),
- NullValueHandling = NullValueHandling.Ignore
- };
}
-}
\ No newline at end of file
+}
+
diff --git a/src/ElectronNET.API/API/BrowserWindow.cs b/src/ElectronNET.API/API/BrowserWindow.cs
index 0c0e54a1..454ab8c0 100644
--- a/src/ElectronNET.API/API/BrowserWindow.cs
+++ b/src/ElectronNET.API/API/BrowserWindow.cs
@@ -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;
///
/// Create and control browser windows.
@@ -469,7 +463,7 @@ internal BrowserWindow(int id)
/// The aspect ratio to maintain for some portion of the content view.
/// The extra size not to be included while maintaining the aspect ratio.
public void SetAspectRatio(double aspectRatio, Size extraSize) =>
- this.CallMethod2(aspectRatio, JObject.FromObject(extraSize, _jsonSerializer));
+ this.CallMethod2(aspectRatio, extraSize);
///
/// This will make a window maintain an aspect ratio. The extra size allows a developer to have space,
@@ -486,7 +480,7 @@ public void SetAspectRatio(double aspectRatio, Size extraSize) =>
/// The aspect ratio to maintain for some portion of the content view.
/// The extra size not to be included while maintaining the aspect ratio.
public void SetAspectRatio(int aspectRatio, Size extraSize) =>
- this.CallMethod2(aspectRatio, JObject.FromObject(extraSize, _jsonSerializer));
+ this.CallMethod2(aspectRatio, extraSize);
///
/// Uses Quick Look to preview a file at a given path.
@@ -515,14 +509,14 @@ public void SetAspectRatio(int aspectRatio, Size extraSize) =>
/// Resizes and moves the window to the supplied bounds
///
///
- public void SetBounds(Rectangle bounds) => this.CallMethod1(JObject.FromObject(bounds, _jsonSerializer));
+ public void SetBounds(Rectangle bounds) => this.CallMethod1(bounds);
///
/// Resizes and moves the window to the supplied bounds
///
///
///
- 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);
///
/// Gets the bounds asynchronous.
@@ -534,14 +528,14 @@ public void SetAspectRatio(int aspectRatio, Size extraSize) =>
/// Resizes and moves the window’s client area (e.g. the web page) to the supplied bounds.
///
///
- public void SetContentBounds(Rectangle bounds) => this.CallMethod1(JObject.FromObject(bounds, _jsonSerializer));
+ public void SetContentBounds(Rectangle bounds) => this.CallMethod1(bounds);
///
/// Resizes and moves the window’s client area (e.g. the web page) to the supplied bounds.
///
///
///
- 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);
///
/// Gets the content bounds asynchronous.
@@ -749,10 +743,10 @@ public void SetPosition(int x, int y)
{
// 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 void SetPosition(int x, int y, bool animate)
{
// 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 @@ private bool isWindows10()
///
///
///
- 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);
///
/// Same as webContents.reload.
@@ -925,13 +920,13 @@ public IReadOnlyCollection