mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-07-18 14:47:43 +00:00
Merge pull request #939 from softworkz/submit_cleanup
Cleanup & Consistency
This commit is contained in:
@@ -206,10 +206,10 @@ namespace ElectronNET.API
|
||||
[SupportedOSPlatform("Windows")]
|
||||
public Task ShowCertificateTrustDialogAsync(BrowserWindow browserWindow, CertificateTrustDialogOptions options)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
var tcs = new TaskCompletionSource();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.Once("showCertificateTrustDialogComplete" + guid, () => tcs.SetResult(null));
|
||||
BridgeConnector.Socket.Once("showCertificateTrustDialogComplete" + guid, () => tcs.SetResult());
|
||||
BridgeConnector.Socket.Emit("showCertificateTrustDialog",
|
||||
browserWindow,
|
||||
options,
|
||||
|
||||
@@ -47,10 +47,10 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task ClearAuthCacheAsync(RemovePassword options)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
var tcs = new TaskCompletionSource();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.Once("webContents-session-clearAuthCache-completed" + guid, () => tcs.SetResult(null));
|
||||
BridgeConnector.Socket.Once("webContents-session-clearAuthCache-completed" + guid, () => tcs.SetResult());
|
||||
BridgeConnector.Socket.Emit("webContents-session-clearAuthCache", Id, options, guid);
|
||||
|
||||
return tcs.Task;
|
||||
@@ -61,10 +61,10 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
public Task ClearAuthCacheAsync()
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
var tcs = new TaskCompletionSource();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.Once("webContents-session-clearAuthCache-completed" + guid, () => tcs.SetResult(null));
|
||||
BridgeConnector.Socket.Once("webContents-session-clearAuthCache-completed" + guid, () => tcs.SetResult());
|
||||
BridgeConnector.Socket.Emit("webContents-session-clearAuthCache", Id, guid);
|
||||
|
||||
return tcs.Task;
|
||||
@@ -76,10 +76,10 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task ClearCacheAsync()
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
var tcs = new TaskCompletionSource();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.Once("webContents-session-clearCache-completed" + guid, () => tcs.SetResult(null));
|
||||
BridgeConnector.Socket.Once("webContents-session-clearCache-completed" + guid, () => tcs.SetResult());
|
||||
BridgeConnector.Socket.Emit("webContents-session-clearCache", Id, guid);
|
||||
|
||||
return tcs.Task;
|
||||
@@ -91,10 +91,10 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task ClearHostResolverCacheAsync()
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
var tcs = new TaskCompletionSource();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.Once("webContents-session-clearHostResolverCache-completed" + guid, () => tcs.SetResult(null));
|
||||
BridgeConnector.Socket.Once("webContents-session-clearHostResolverCache-completed" + guid, () => tcs.SetResult());
|
||||
BridgeConnector.Socket.Emit("webContents-session-clearHostResolverCache", Id, guid);
|
||||
|
||||
return tcs.Task;
|
||||
@@ -106,10 +106,10 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task ClearStorageDataAsync()
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
var tcs = new TaskCompletionSource();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.Once("webContents-session-clearStorageData-completed" + guid, () => tcs.SetResult(null));
|
||||
BridgeConnector.Socket.Once("webContents-session-clearStorageData-completed" + guid, () => tcs.SetResult());
|
||||
BridgeConnector.Socket.Emit("webContents-session-clearStorageData", Id, guid);
|
||||
|
||||
return tcs.Task;
|
||||
@@ -122,10 +122,10 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task ClearStorageDataAsync(ClearStorageDataOptions options)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
var tcs = new TaskCompletionSource();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.Once("webContents-session-clearStorageData-options-completed" + guid, () => tcs.SetResult(null));
|
||||
BridgeConnector.Socket.Once("webContents-session-clearStorageData-options-completed" + guid, () => tcs.SetResult());
|
||||
BridgeConnector.Socket.Emit("webContents-session-clearStorageData-options", Id, options, guid);
|
||||
|
||||
return tcs.Task;
|
||||
@@ -276,10 +276,10 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task SetProxyAsync(ProxyConfig config)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
var tcs = new TaskCompletionSource();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.Once("webContents-session-setProxy-completed" + guid, () => tcs.SetResult(null));
|
||||
BridgeConnector.Socket.Once("webContents-session-setProxy-completed" + guid, () => tcs.SetResult());
|
||||
BridgeConnector.Socket.Emit("webContents-session-setProxy", Id, config, guid);
|
||||
|
||||
return tcs.Task;
|
||||
|
||||
@@ -42,13 +42,9 @@ namespace ElectronNET.API
|
||||
/// <param name="fullPath">The full path to the directory / file.</param>
|
||||
public Task ShowItemInFolderAsync(string fullPath)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
|
||||
// Is this really useful?
|
||||
BridgeConnector.Socket.Once("shell-showItemInFolderCompleted", () => { });
|
||||
BridgeConnector.Socket.Emit("shell-showItemInFolder", fullPath);
|
||||
|
||||
return tcs.Task;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -254,12 +254,12 @@ public class WebContents : ApiBase
|
||||
/// <param name="options"></param>
|
||||
public Task LoadURLAsync(string url, LoadURLOptions options)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
var tcs = new TaskCompletionSource();
|
||||
|
||||
BridgeConnector.Socket.Once("webContents-loadURL-complete" + Id, () =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("webContents-loadURL-error" + Id);
|
||||
tcs.SetResult(null);
|
||||
tcs.SetResult();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Once<string>("webContents-loadURL-error" + Id, (error) => { tcs.SetException(new InvalidOperationException(error)); });
|
||||
|
||||
@@ -2,12 +2,10 @@
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace ElectronNET.API;
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using ElectronNET.API.Serialization;
|
||||
using SocketIO.Serializer.SystemTextJson;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using SocketIO = SocketIOClient.SocketIO;
|
||||
|
||||
internal class SocketIoFacade
|
||||
@@ -66,20 +64,6 @@ internal class SocketIoFacade
|
||||
}
|
||||
}
|
||||
|
||||
// Keep object overload for compatibility; value will be a JsonElement boxed as object.
|
||||
public void On(string eventName, Action<object> action)
|
||||
{
|
||||
lock (_lockObj)
|
||||
{
|
||||
_socket.On(eventName, response =>
|
||||
{
|
||||
var value = (object)response.GetValue<JsonElement>();
|
||||
////Console.WriteLine($"Called Event {eventName} - data {value}");
|
||||
Task.Run(() => action(value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void Once(string eventName, Action action)
|
||||
{
|
||||
lock (_lockObj)
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<ImportNuGetBuildTasksPackTargetsFromSdk>false</ImportNuGetBuildTasksPackTargetsFromSdk>
|
||||
<PublishTrimmed>False</PublishTrimmed>
|
||||
<NuGetAudit>false</NuGetAudit>
|
||||
<Nullable>disable</Nullable>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="ElectronNetCommon">
|
||||
<PackageIcon>128.png</PackageIcon>
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
<PropertyGroup>
|
||||
<TypeScriptCompileOnSaveEnabled>true</TypeScriptCompileOnSaveEnabled>
|
||||
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
|
||||
<Nullable>disable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Remove="publish\**" />
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<Description>$(DescriptionFirstPart) This package contains the ElectronNET project system.</Description>
|
||||
<GenerateDocumentationFile>false</GenerateDocumentationFile>
|
||||
<IncludeSymbols>false</IncludeSymbols>
|
||||
<Nullable>disable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Include="PackageIcon.png" Pack="true" PackagePath="\" />
|
||||
|
||||
Reference in New Issue
Block a user