mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-13 05:34:47 +00:00
ApiBase: Rename PropertyGet to more generic Invocator
This commit is contained in:
@@ -29,15 +29,15 @@ namespace ElectronNET.API
|
||||
CamelCase,
|
||||
}
|
||||
|
||||
private const int PropertyTimeout = 1000;
|
||||
private const int InvocationTimeout = 1000;
|
||||
|
||||
private readonly string objectName;
|
||||
private readonly ConcurrentDictionary<string, PropertyGetter> propertyGetters;
|
||||
private readonly ConcurrentDictionary<string, string> propertyEventNames = new();
|
||||
private readonly ConcurrentDictionary<string, string> propertyMessageNames = new();
|
||||
private readonly ConcurrentDictionary<string, Invocator> invocators;
|
||||
private readonly ConcurrentDictionary<string, string> invocationEventNames = new();
|
||||
private readonly ConcurrentDictionary<string, string> invocationMessageNames = new();
|
||||
private readonly ConcurrentDictionary<string, string> methodMessageNames = new();
|
||||
private static readonly ConcurrentDictionary<string, EventContainer> eventContainers = new();
|
||||
private static readonly ConcurrentDictionary<string, ConcurrentDictionary<string, PropertyGetter>> AllPropertyGetters = new();
|
||||
private static readonly ConcurrentDictionary<string, ConcurrentDictionary<string, Invocator>> AllInvocators = new();
|
||||
|
||||
private readonly object objLock = new object();
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace ElectronNET.API
|
||||
protected ApiBase()
|
||||
{
|
||||
this.objectName = this.GetType().Name.LowerFirst();
|
||||
propertyGetters = AllPropertyGetters.GetOrAdd(objectName, _ => new ConcurrentDictionary<string, PropertyGetter>());
|
||||
this.invocators = AllInvocators.GetOrAdd(objectName, _ => new ConcurrentDictionary<string, Invocator>());
|
||||
}
|
||||
|
||||
protected void CallMethod0([CallerMemberName] string callerName = null)
|
||||
@@ -113,21 +113,21 @@ namespace ElectronNET.API
|
||||
}
|
||||
}
|
||||
|
||||
protected Task<T> GetPropertyAsync<T>(object arg = null, [CallerMemberName] string callerName = null)
|
||||
protected Task<T> InvokeAsync<T>(object arg = null, [CallerMemberName] string callerName = null)
|
||||
{
|
||||
Debug.Assert(callerName != null, nameof(callerName) + " != null");
|
||||
|
||||
lock (this.objLock)
|
||||
{
|
||||
return this.propertyGetters.GetOrAdd(callerName, _ =>
|
||||
return this.invocators.GetOrAdd(callerName, _ =>
|
||||
{
|
||||
var getter = new PropertyGetter<T>(this, callerName, PropertyTimeout, arg);
|
||||
var getter = new Invocator<T>(this, callerName, InvocationTimeout, arg);
|
||||
|
||||
getter.Task<T>().ContinueWith(_ =>
|
||||
{
|
||||
lock (this.objLock)
|
||||
{
|
||||
return this.propertyGetters.TryRemove(callerName, out var _);
|
||||
return this.invocators.TryRemove(callerName, out var _);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -228,17 +228,17 @@ namespace ElectronNET.API
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0}{1:D}", eventName, id);
|
||||
}
|
||||
|
||||
internal abstract class PropertyGetter
|
||||
internal abstract class Invocator
|
||||
{
|
||||
public abstract Task<T> Task<T>();
|
||||
}
|
||||
|
||||
internal class PropertyGetter<T> : PropertyGetter
|
||||
internal class Invocator<T> : Invocator
|
||||
{
|
||||
private readonly Task<T> tcsTask;
|
||||
private TaskCompletionSource<T> tcs;
|
||||
|
||||
public PropertyGetter(ApiBase apiBase, string callerName, int timeoutMs, object arg = null)
|
||||
public Invocator(ApiBase apiBase, string callerName, int timeoutMs, object arg = null)
|
||||
{
|
||||
this.tcs = new TaskCompletionSource<T>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
this.tcsTask = this.tcs.Task;
|
||||
@@ -249,10 +249,10 @@ namespace ElectronNET.API
|
||||
switch (apiBase.SocketTaskEventNameType)
|
||||
{
|
||||
case SocketTaskEventNameTypes.DashesLowerFirst:
|
||||
eventName = apiBase.propertyEventNames.GetOrAdd(callerName, s => $"{apiBase.objectName}-{s.StripAsync().LowerFirst()}-completed");
|
||||
eventName = apiBase.invocationEventNames.GetOrAdd(callerName, s => $"{apiBase.objectName}-{s.StripAsync().LowerFirst()}-completed");
|
||||
break;
|
||||
case SocketTaskEventNameTypes.NoDashUpperFirst:
|
||||
eventName = apiBase.propertyEventNames.GetOrAdd(callerName, s => $"{apiBase.objectName}{s.StripAsync()}Completed");
|
||||
eventName = apiBase.invocationEventNames.GetOrAdd(callerName, s => $"{apiBase.objectName}{s.StripAsync()}Completed");
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
@@ -261,10 +261,10 @@ namespace ElectronNET.API
|
||||
switch (apiBase.SocketTaskMessageNameType)
|
||||
{
|
||||
case SocketTaskMessageNameTypes.DashesLowerFirst:
|
||||
messageName = apiBase.propertyMessageNames.GetOrAdd(callerName, s => $"{apiBase.objectName}-{s.StripAsync().LowerFirst()}");
|
||||
messageName = apiBase.invocationMessageNames.GetOrAdd(callerName, s => $"{apiBase.objectName}-{s.StripAsync().LowerFirst()}");
|
||||
break;
|
||||
case SocketTaskMessageNameTypes.NoDashUpperFirst:
|
||||
messageName = apiBase.propertyMessageNames.GetOrAdd(callerName, s => apiBase.objectName + s.StripAsync());
|
||||
messageName = apiBase.invocationMessageNames.GetOrAdd(callerName, s => apiBase.objectName + s.StripAsync());
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
@@ -299,7 +299,7 @@ namespace ElectronNET.API
|
||||
_ = apiBase.Id >= 0 ? BridgeConnector.Socket.Emit(messageName, apiBase.Id) : BridgeConnector.Socket.Emit(messageName);
|
||||
}
|
||||
|
||||
System.Threading.Tasks.Task.Delay(PropertyTimeout).ContinueWith(_ =>
|
||||
System.Threading.Tasks.Task.Delay(InvocationTimeout).ContinueWith(_ =>
|
||||
{
|
||||
if (this.tcs != null)
|
||||
{
|
||||
|
||||
@@ -366,7 +366,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.GetPropertyAsync<string>();
|
||||
return this.InvokeAsync<string>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -501,7 +501,7 @@ namespace ElectronNET.API
|
||||
public async Task<string> GetAppPathAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return await this.GetPropertyAsync<string>().ConfigureAwait(false);
|
||||
return await this.InvokeAsync<string>().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -565,7 +565,7 @@ namespace ElectronNET.API
|
||||
public async Task<string> GetVersionAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return await this.GetPropertyAsync<string>().ConfigureAwait(false);
|
||||
return await this.InvokeAsync<string>().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -579,7 +579,7 @@ namespace ElectronNET.API
|
||||
public async Task<string> GetLocaleAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return await this.GetPropertyAsync<string>().ConfigureAwait(false);
|
||||
return await this.InvokeAsync<string>().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -850,7 +850,7 @@ namespace ElectronNET.API
|
||||
public async Task<JumpListSettings> GetJumpListSettingsAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return await this.GetPropertyAsync<JumpListSettings>().ConfigureAwait(false);
|
||||
return await this.InvokeAsync<JumpListSettings>().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -941,7 +941,7 @@ namespace ElectronNET.API
|
||||
public async Task<bool> HasSingleInstanceLockAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return await this.GetPropertyAsync<bool>().ConfigureAwait(false);
|
||||
return await this.InvokeAsync<bool>().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -980,7 +980,7 @@ namespace ElectronNET.API
|
||||
public async Task<string> GetCurrentActivityTypeAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return await this.GetPropertyAsync<string>().ConfigureAwait(false);
|
||||
return await this.InvokeAsync<string>().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1043,7 +1043,7 @@ namespace ElectronNET.API
|
||||
public async Task<ProcessMetric[]> GetAppMetricsAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return await this.GetPropertyAsync<ProcessMetric[]>().ConfigureAwait(false);
|
||||
return await this.InvokeAsync<ProcessMetric[]>().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1055,7 +1055,7 @@ namespace ElectronNET.API
|
||||
public async Task<GPUFeatureStatus> GetGpuFeatureStatusAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return await this.GetPropertyAsync<GPUFeatureStatus>().ConfigureAwait(false);
|
||||
return await this.InvokeAsync<GPUFeatureStatus>().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1090,7 +1090,7 @@ namespace ElectronNET.API
|
||||
public async Task<int> GetBadgeCountAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return await this.GetPropertyAsync<int>().ConfigureAwait(false);
|
||||
return await this.InvokeAsync<int>().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1105,7 +1105,7 @@ namespace ElectronNET.API
|
||||
public async Task<bool> IsUnityRunningAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return await this.GetPropertyAsync<bool>().ConfigureAwait(false);
|
||||
return await this.InvokeAsync<bool>().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1166,7 +1166,7 @@ namespace ElectronNET.API
|
||||
public async Task<bool> IsAccessibilitySupportEnabledAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return await this.GetPropertyAsync<bool>().ConfigureAwait(false);
|
||||
return await this.InvokeAsync<bool>().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run(() => GetPropertyAsync<bool>()).Result;
|
||||
return Task.Run(() => this.InvokeAsync<bool>()).Result;
|
||||
}
|
||||
set
|
||||
{
|
||||
@@ -40,7 +40,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run(() => GetPropertyAsync<bool>()).Result;
|
||||
return Task.Run(() => this.InvokeAsync<bool>()).Result;
|
||||
}
|
||||
set
|
||||
{
|
||||
@@ -58,7 +58,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run(() => GetPropertyAsync<bool>()).Result;
|
||||
return Task.Run(() => this.InvokeAsync<bool>()).Result;
|
||||
}
|
||||
set
|
||||
{
|
||||
@@ -74,7 +74,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run(() => GetPropertyAsync<bool>()).Result;
|
||||
return Task.Run(() => this.InvokeAsync<bool>()).Result;
|
||||
}
|
||||
set
|
||||
{
|
||||
@@ -91,7 +91,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run(() => GetPropertyAsync<bool>()).Result;
|
||||
return Task.Run(() => this.InvokeAsync<bool>()).Result;
|
||||
}
|
||||
set
|
||||
{
|
||||
@@ -106,7 +106,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run(() => GetPropertyAsync<string>()).Result;
|
||||
return Task.Run(() => this.InvokeAsync<string>()).Result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run(() => GetPropertyAsync<SemVer>());
|
||||
return Task.Run(() => this.InvokeAsync<SemVer>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run(() => GetPropertyAsync<string>());
|
||||
return Task.Run(() => this.InvokeAsync<string>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run(() => GetPropertyAsync<Dictionary<string, string>>());
|
||||
return Task.Run(() => this.InvokeAsync<Dictionary<string, string>>());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run(() => GetPropertyAsync<Rectangle>()).Result;
|
||||
return Task.Run(() => this.InvokeAsync<Rectangle>()).Result;
|
||||
}
|
||||
set
|
||||
{
|
||||
|
||||
@@ -313,13 +313,13 @@ public class BrowserWindow : ApiBase
|
||||
/// Whether the window is focused.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsFocusedAsync() => this.GetPropertyAsync<bool>();
|
||||
public Task<bool> IsFocusedAsync() => this.InvokeAsync<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// Whether the window is destroyed.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsDestroyedAsync() => this.GetPropertyAsync<bool>();
|
||||
public Task<bool> IsDestroyedAsync() => this.InvokeAsync<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// Shows and gives focus to the window.
|
||||
@@ -340,13 +340,13 @@ public class BrowserWindow : ApiBase
|
||||
/// Whether the window is visible to the user.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsVisibleAsync() => this.GetPropertyAsync<bool>();
|
||||
public Task<bool> IsVisibleAsync() => this.InvokeAsync<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// Whether current window is a modal window.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsModalAsync() => this.GetPropertyAsync<bool>();
|
||||
public Task<bool> IsModalAsync() => this.InvokeAsync<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// Maximizes the window. This will also show (but not focus) the window if it isn’t being displayed already.
|
||||
@@ -362,7 +362,7 @@ public class BrowserWindow : ApiBase
|
||||
/// Whether the window is maximized.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsMaximizedAsync() => this.GetPropertyAsync<bool>();
|
||||
public Task<bool> IsMaximizedAsync() => this.InvokeAsync<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// Minimizes the window. On some platforms the minimized window will be shown in the Dock.
|
||||
@@ -378,7 +378,7 @@ public class BrowserWindow : ApiBase
|
||||
/// Whether the window is minimized.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsMinimizedAsync() => this.GetPropertyAsync<bool>();
|
||||
public Task<bool> IsMinimizedAsync() => this.InvokeAsync<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// Sets whether the window should be in fullscreen mode.
|
||||
@@ -390,7 +390,7 @@ public class BrowserWindow : ApiBase
|
||||
/// Whether the window is in fullscreen mode.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsFullScreenAsync() => this.GetPropertyAsync<bool>();
|
||||
public Task<bool> IsFullScreenAsync() => this.InvokeAsync<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// This will make a window maintain an aspect ratio. The extra size allows a developer to have space,
|
||||
@@ -466,7 +466,7 @@ public class BrowserWindow : ApiBase
|
||||
/// Gets the bounds asynchronous.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<Rectangle> GetBoundsAsync() => this.GetPropertyAsync<Rectangle>();
|
||||
public Task<Rectangle> GetBoundsAsync() => this.InvokeAsync<Rectangle>();
|
||||
|
||||
/// <summary>
|
||||
/// Resizes and moves the window’s client area (e.g. the web page) to the supplied bounds.
|
||||
@@ -485,7 +485,7 @@ public class BrowserWindow : ApiBase
|
||||
/// Gets the content bounds asynchronous.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<Rectangle> GetContentBoundsAsync() => this.GetPropertyAsync<Rectangle>();
|
||||
public Task<Rectangle> GetContentBoundsAsync() => this.InvokeAsync<Rectangle>();
|
||||
|
||||
/// <summary>
|
||||
/// Resizes the window to width and height.
|
||||
@@ -506,7 +506,7 @@ public class BrowserWindow : ApiBase
|
||||
/// Contains the window’s width and height.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<int[]> GetSizeAsync() => this.GetPropertyAsync<int[]>();
|
||||
public Task<int[]> GetSizeAsync() => this.InvokeAsync<int[]>();
|
||||
|
||||
/// <summary>
|
||||
/// Resizes the window’s client area (e.g. the web page) to width and height.
|
||||
@@ -527,7 +527,7 @@ public class BrowserWindow : ApiBase
|
||||
/// Contains the window’s client area’s width and height.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<int[]> GetContentSizeAsync() => this.GetPropertyAsync<int[]>();
|
||||
public Task<int[]> GetContentSizeAsync() => this.InvokeAsync<int[]>();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the minimum size of window to width and height.
|
||||
@@ -540,7 +540,7 @@ public class BrowserWindow : ApiBase
|
||||
/// Contains the window’s minimum width and height.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<int[]> GetMinimumSizeAsync() => this.GetPropertyAsync<int[]>();
|
||||
public Task<int[]> GetMinimumSizeAsync() => this.InvokeAsync<int[]>();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the maximum size of window to width and height.
|
||||
@@ -553,7 +553,7 @@ public class BrowserWindow : ApiBase
|
||||
/// Contains the window’s maximum width and height.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<int[]> GetMaximumSizeAsync() => this.GetPropertyAsync<int[]>();
|
||||
public Task<int[]> GetMaximumSizeAsync() => this.InvokeAsync<int[]>();
|
||||
|
||||
/// <summary>
|
||||
/// Sets whether the window can be manually resized by user.
|
||||
@@ -565,7 +565,7 @@ public class BrowserWindow : ApiBase
|
||||
/// Whether the window can be manually resized by user.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsResizableAsync() => this.GetPropertyAsync<bool>();
|
||||
public Task<bool> IsResizableAsync() => this.InvokeAsync<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// Sets whether the window can be moved by user. On Linux does nothing.
|
||||
@@ -579,7 +579,7 @@ public class BrowserWindow : ApiBase
|
||||
/// On Linux always returns true.
|
||||
/// </summary>
|
||||
/// <returns>On Linux always returns true.</returns>
|
||||
public Task<bool> IsMovableAsync() => this.GetPropertyAsync<bool>();
|
||||
public Task<bool> IsMovableAsync() => this.InvokeAsync<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// Sets whether the window can be manually minimized by user. On Linux does nothing.
|
||||
@@ -593,7 +593,7 @@ public class BrowserWindow : ApiBase
|
||||
/// On Linux always returns true.
|
||||
/// </summary>
|
||||
/// <returns>On Linux always returns true.</returns>
|
||||
public Task<bool> IsMinimizableAsync() => this.GetPropertyAsync<bool>();
|
||||
public Task<bool> IsMinimizableAsync() => this.InvokeAsync<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// Sets whether the window can be manually maximized by user. On Linux does nothing.
|
||||
@@ -607,7 +607,7 @@ public class BrowserWindow : ApiBase
|
||||
/// On Linux always returns true.
|
||||
/// </summary>
|
||||
/// <returns>On Linux always returns true.</returns>
|
||||
public Task<bool> IsMaximizableAsync() => this.GetPropertyAsync<bool>();
|
||||
public Task<bool> IsMaximizableAsync() => this.InvokeAsync<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// Sets whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.
|
||||
@@ -619,7 +619,7 @@ public class BrowserWindow : ApiBase
|
||||
/// Whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsFullScreenableAsync() => this.GetPropertyAsync<bool>();
|
||||
public Task<bool> IsFullScreenableAsync() => this.InvokeAsync<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// Sets whether the window can be manually closed by user. On Linux does nothing.
|
||||
@@ -633,7 +633,7 @@ public class BrowserWindow : ApiBase
|
||||
/// On Linux always returns true.
|
||||
/// </summary>
|
||||
/// <returns>On Linux always returns true.</returns>
|
||||
public Task<bool> IsClosableAsync() => this.GetPropertyAsync<bool>();
|
||||
public Task<bool> IsClosableAsync() => this.InvokeAsync<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// Sets whether the window should show always on top of other windows.
|
||||
@@ -671,7 +671,7 @@ public class BrowserWindow : ApiBase
|
||||
/// Whether the window is always on top of other windows.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsAlwaysOnTopAsync() => this.GetPropertyAsync<bool>();
|
||||
public Task<bool> IsAlwaysOnTopAsync() => this.InvokeAsync<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// Moves window to the center of the screen.
|
||||
@@ -721,7 +721,7 @@ public class BrowserWindow : ApiBase
|
||||
/// Contains the window’s current position.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<int[]> GetPositionAsync() => this.GetPropertyAsync<int[]>();
|
||||
public Task<int[]> GetPositionAsync() => this.InvokeAsync<int[]>();
|
||||
|
||||
/// <summary>
|
||||
/// Changes the title of native window to title.
|
||||
@@ -735,7 +735,7 @@ public class BrowserWindow : ApiBase
|
||||
/// Note: The title of web page can be different from the title of the native window.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<string> GetTitleAsync() => this.GetPropertyAsync<string>();
|
||||
public Task<string> GetTitleAsync() => this.InvokeAsync<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Changes the attachment point for sheets on macOS.
|
||||
@@ -776,13 +776,13 @@ public class BrowserWindow : ApiBase
|
||||
/// Whether the window is in kiosk mode.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsKioskAsync() => this.GetPropertyAsync<bool>();
|
||||
public Task<bool> IsKioskAsync() => this.InvokeAsync<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the native type of the handle is HWND on Windows, NSView* on macOS, and Window (unsigned long) on Linux.
|
||||
/// </summary>
|
||||
/// <returns>string of the native handle obtained, HWND on Windows, NSView* on macOS, and Window (unsigned long) on Linux.</returns>
|
||||
public Task<string> GetNativeWindowHandle() => this.GetPropertyAsync<string>();
|
||||
public Task<string> GetNativeWindowHandle() => this.InvokeAsync<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the pathname of the file the window represents,
|
||||
@@ -795,7 +795,7 @@ public class BrowserWindow : ApiBase
|
||||
/// The pathname of the file the window represents.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<string> GetRepresentedFilenameAsync() => this.GetPropertyAsync<string>();
|
||||
public Task<string> GetRepresentedFilenameAsync() => this.InvokeAsync<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the window’s document has been edited,
|
||||
@@ -808,7 +808,7 @@ public class BrowserWindow : ApiBase
|
||||
/// Whether the window’s document has been edited.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsDocumentEditedAsync() => this.GetPropertyAsync<bool>();
|
||||
public Task<bool> IsDocumentEditedAsync() => this.InvokeAsync<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// Focuses the on web view.
|
||||
@@ -920,7 +920,7 @@ public class BrowserWindow : ApiBase
|
||||
/// On Windows and Linux always returns true.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<bool> HasShadowAsync() => this.GetPropertyAsync<bool>();
|
||||
public Task<bool> HasShadowAsync() => this.InvokeAsync<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the thumbar buttons.
|
||||
@@ -1012,7 +1012,7 @@ public class BrowserWindow : ApiBase
|
||||
/// Whether menu bar automatically hides itself.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsMenuBarAutoHideAsync() => this.GetPropertyAsync<bool>();
|
||||
public Task<bool> IsMenuBarAutoHideAsync() => this.InvokeAsync<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// Sets whether the menu bar should be visible. If the menu bar is auto-hide,
|
||||
@@ -1025,7 +1025,7 @@ public class BrowserWindow : ApiBase
|
||||
/// Whether the menu bar is visible.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsMenuBarVisibleAsync() => this.GetPropertyAsync<bool>();
|
||||
public Task<bool> IsMenuBarVisibleAsync() => this.InvokeAsync<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// Sets whether the window should be visible on all workspaces.
|
||||
@@ -1041,7 +1041,7 @@ public class BrowserWindow : ApiBase
|
||||
/// Note: This API always returns false on Windows.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsVisibleOnAllWorkspacesAsync() => this.GetPropertyAsync<bool>();
|
||||
public Task<bool> IsVisibleOnAllWorkspacesAsync() => this.InvokeAsync<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// Makes the window ignore all mouse events.
|
||||
@@ -1090,7 +1090,7 @@ public class BrowserWindow : ApiBase
|
||||
/// <returns></returns>
|
||||
public async Task<BrowserWindow> GetParentWindowAsync()
|
||||
{
|
||||
var browserWindowId = await this.GetPropertyAsync<int>().ConfigureAwait(false);
|
||||
var browserWindowId = await this.InvokeAsync<int>().ConfigureAwait(false);
|
||||
var browserWindow = Electron.WindowManager.BrowserWindows.ToList().Single(x => x.Id == browserWindowId);
|
||||
return browserWindow;
|
||||
}
|
||||
@@ -1101,7 +1101,7 @@ public class BrowserWindow : ApiBase
|
||||
/// <returns></returns>
|
||||
public async Task<List<BrowserWindow>> GetChildWindowsAsync()
|
||||
{
|
||||
var browserWindowIds = await this.GetPropertyAsync<int[]>().ConfigureAwait(false);
|
||||
var browserWindowIds = await this.InvokeAsync<int[]>().ConfigureAwait(false);
|
||||
var browserWindows = new List<BrowserWindow>();
|
||||
|
||||
foreach (var id in browserWindowIds)
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns>The content in the clipboard as plain text.</returns>
|
||||
public Task<string> ReadTextAsync(string type = "") => GetPropertyAsync<string>(type);
|
||||
public Task<string> ReadTextAsync(string type = "") => this.InvokeAsync<string>(type);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the text into the clipboard as plain text.
|
||||
@@ -62,7 +62,7 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public Task<string> ReadHTMLAsync(string type = "") => GetPropertyAsync<string>(type);
|
||||
public Task<string> ReadHTMLAsync(string type = "") => this.InvokeAsync<string>(type);
|
||||
|
||||
/// <summary>
|
||||
/// Writes markup to the clipboard.
|
||||
@@ -79,7 +79,7 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public Task<string> ReadRTFAsync(string type = "") => GetPropertyAsync<string>(type);
|
||||
public Task<string> ReadRTFAsync(string type = "") => this.InvokeAsync<string>(type);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the text into the clipboard in RTF.
|
||||
@@ -97,7 +97,7 @@ namespace ElectronNET.API
|
||||
/// be empty strings when the bookmark is unavailable.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<ReadBookmark> ReadBookmarkAsync() => GetPropertyAsync<ReadBookmark>();
|
||||
public Task<ReadBookmark> ReadBookmarkAsync() => this.InvokeAsync<ReadBookmark>();
|
||||
|
||||
/// <summary>
|
||||
/// Writes the title and url into the clipboard as a bookmark.
|
||||
@@ -120,7 +120,7 @@ namespace ElectronNET.API
|
||||
/// find pasteboard whenever the application is activated.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<string> ReadFindTextAsync() => GetPropertyAsync<string>();
|
||||
public Task<string> ReadFindTextAsync() => this.InvokeAsync<string>();
|
||||
|
||||
/// <summary>
|
||||
/// macOS: Writes the text into the find pasteboard as plain text. This method uses
|
||||
@@ -146,7 +146,7 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public Task<string[]> AvailableFormatsAsync(string type = "") => GetPropertyAsync<string[]>(type);
|
||||
public Task<string[]> AvailableFormatsAsync(string type = "") => this.InvokeAsync<string[]>(type);
|
||||
|
||||
/// <summary>
|
||||
/// Writes data to the clipboard.
|
||||
@@ -163,7 +163,7 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public Task<NativeImage> ReadImageAsync(string type = "") => GetPropertyAsync<NativeImage>(type);
|
||||
public Task<NativeImage> ReadImageAsync(string type = "") => this.InvokeAsync<NativeImage>(type);
|
||||
|
||||
/// <summary>
|
||||
/// Writes an image to the clipboard.
|
||||
|
||||
@@ -107,26 +107,26 @@ namespace ElectronNET.API
|
||||
/// A <see cref="ThemeSourceMode"/> property that can be <see cref="ThemeSourceMode.System"/>, <see cref="ThemeSourceMode.Light"/> or <see cref="ThemeSourceMode.Dark"/>. It is used to override (<seealso cref="SetThemeSource"/>) and
|
||||
/// supercede the value that Chromium has chosen to use internally.
|
||||
/// </summary>
|
||||
public Task<ThemeSourceMode> GetThemeSourceAsync() => GetPropertyAsync<ThemeSourceMode>();
|
||||
public Task<ThemeSourceMode> GetThemeSourceAsync() => this.InvokeAsync<ThemeSourceMode>();
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="bool"/> for if the OS / Chromium currently has a dark mode enabled or is
|
||||
/// being instructed to show a dark-style UI. If you want to modify this value you
|
||||
/// should use <see cref="SetThemeSource"/>.
|
||||
/// </summary>
|
||||
public Task<bool> ShouldUseDarkColorsAsync() => GetPropertyAsync<bool>();
|
||||
public Task<bool> ShouldUseDarkColorsAsync() => this.InvokeAsync<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="bool"/> for if the OS / Chromium currently has high-contrast mode enabled or is
|
||||
/// being instructed to show a high-contrast UI.
|
||||
/// </summary>
|
||||
public Task<bool> ShouldUseHighContrastColorsAsync() => GetPropertyAsync<bool>();
|
||||
public Task<bool> ShouldUseHighContrastColorsAsync() => this.InvokeAsync<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="bool"/> for if the OS / Chromium currently has an inverted color scheme or is
|
||||
/// being instructed to use an inverted color scheme.
|
||||
/// </summary>
|
||||
public Task<bool> ShouldUseInvertedColorSchemeAsync() => GetPropertyAsync<bool>();
|
||||
public Task<bool> ShouldUseInvertedColorSchemeAsync() => this.InvokeAsync<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// Emitted when something in the underlying NativeTheme has changed. This normally means that either the value of <see cref="ShouldUseDarkColorsAsync"/>,
|
||||
|
||||
@@ -116,6 +116,6 @@ namespace ElectronNET.API
|
||||
/// Whether or not desktop notifications are supported on the current system.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsSupportedAsync() => GetPropertyAsync<bool>();
|
||||
public Task<bool> IsSupportedAsync() => this.InvokeAsync<bool>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace ElectronNET.API
|
||||
/// The process.execPath property returns the absolute pathname of the executable that
|
||||
/// started the Node.js process. Symbolic links, if any, are resolved.
|
||||
/// </summary>
|
||||
public Task<string> ExecPathAsync => GetPropertyAsync<string>();
|
||||
public Task<string> ExecPathAsync => this.InvokeAsync<string>();
|
||||
|
||||
/// <summary>
|
||||
/// The process.argv property returns an array containing the command-line arguments passed
|
||||
@@ -53,56 +53,56 @@ namespace ElectronNET.API
|
||||
/// will be the path to the JavaScript file being executed. The remaining elements will be
|
||||
/// any additional command-line arguments
|
||||
/// </summary>
|
||||
public Task<string[]> ArgvAsync => GetPropertyAsync<string[]>();
|
||||
public Task<string[]> ArgvAsync => this.InvokeAsync<string[]>();
|
||||
|
||||
/// <summary>
|
||||
/// The process.execPath property returns the absolute pathname of the executable that
|
||||
/// started the Node.js process. Symbolic links, if any, are resolved.
|
||||
/// </summary>
|
||||
public Task<string> TypeAsync => GetPropertyAsync<string>();
|
||||
public Task<string> TypeAsync => this.InvokeAsync<string>();
|
||||
|
||||
/// <summary>
|
||||
/// The process.versions property returns an object listing the version strings of
|
||||
/// chrome and electron.
|
||||
/// </summary>
|
||||
public Task<ProcessVersions> VersionsAsync => GetPropertyAsync<ProcessVersions>();
|
||||
public Task<ProcessVersions> VersionsAsync => this.InvokeAsync<ProcessVersions>();
|
||||
|
||||
/// <summary>
|
||||
/// A Boolean. When app is started by being passed as parameter to the default app, this
|
||||
/// property is true in the main process, otherwise it is false.
|
||||
/// </summary>
|
||||
public Task<bool> DefaultAppAsync => GetPropertyAsync<bool>();
|
||||
public Task<bool> DefaultAppAsync => this.InvokeAsync<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// A Boolean, true when the current renderer context is the "main" renderer frame. If you
|
||||
/// want the ID of the current frame you should use webFrame.routingId
|
||||
/// </summary>
|
||||
public Task<bool> IsMainFrameAsync => GetPropertyAsync<bool>();
|
||||
public Task<bool> IsMainFrameAsync => this.InvokeAsync<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// A String representing the path to the resources directory.
|
||||
/// </summary>
|
||||
public Task<string> ResourcesPathAsync => GetPropertyAsync<string>();
|
||||
public Task<string> ResourcesPathAsync => this.InvokeAsync<string>();
|
||||
|
||||
/// <summary>
|
||||
/// The number of seconds the current Node.js process has been running. The return value
|
||||
/// includes fractions of a second. Use Math.floor() to get whole seconds.
|
||||
/// </summary>
|
||||
public Task<double> UpTimeAsync => GetPropertyAsync<double>();
|
||||
public Task<double> UpTimeAsync => this.InvokeAsync<double>();
|
||||
|
||||
/// <summary>
|
||||
/// The PID of the electron process
|
||||
/// </summary>
|
||||
public Task<int> PidAsync => GetPropertyAsync<int>();
|
||||
public Task<int> PidAsync => this.InvokeAsync<int>();
|
||||
|
||||
/// <summary>
|
||||
/// The operating system CPU architecture for which the Node.js binary was compiled
|
||||
/// </summary>
|
||||
public Task<string> ArchAsync => GetPropertyAsync<string>();
|
||||
public Task<string> ArchAsync => this.InvokeAsync<string>();
|
||||
|
||||
/// <summary>
|
||||
/// A string identifying the operating system platform on which the Node.js process is running
|
||||
/// </summary>
|
||||
public Task<string> PlatformAsync => GetPropertyAsync<string>();
|
||||
public Task<string> PlatformAsync => this.InvokeAsync<string>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,37 +101,37 @@ namespace ElectronNET.API
|
||||
/// The current absolute position of the mouse pointer.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<Point> GetCursorScreenPointAsync() => GetPropertyAsync<Point>();
|
||||
public Task<Point> GetCursorScreenPointAsync() => this.InvokeAsync<Point>();
|
||||
|
||||
/// <summary>
|
||||
/// macOS: The height of the menu bar in pixels.
|
||||
/// </summary>
|
||||
/// <returns>The height of the menu bar in pixels.</returns>
|
||||
public Task<Rectangle> GetMenuBarWorkAreaAsync() => GetPropertyAsync<Rectangle>();
|
||||
public Task<Rectangle> GetMenuBarWorkAreaAsync() => this.InvokeAsync<Rectangle>();
|
||||
|
||||
/// <summary>
|
||||
/// The primary display.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<Display> GetPrimaryDisplayAsync() => GetPropertyAsync<Display>();
|
||||
public Task<Display> GetPrimaryDisplayAsync() => this.InvokeAsync<Display>();
|
||||
|
||||
/// <summary>
|
||||
/// An array of displays that are currently available.
|
||||
/// </summary>
|
||||
/// <returns>An array of displays that are currently available.</returns>
|
||||
public Task<Display[]> GetAllDisplaysAsync() => GetPropertyAsync<Display[]>();
|
||||
public Task<Display[]> GetAllDisplaysAsync() => this.InvokeAsync<Display[]>();
|
||||
|
||||
/// <summary>
|
||||
/// The display nearest the specified point.
|
||||
/// </summary>
|
||||
/// <returns>The display nearest the specified point.</returns>
|
||||
public Task<Display> GetDisplayNearestPointAsync(Point point) => GetPropertyAsync<Display>(point);
|
||||
public Task<Display> GetDisplayNearestPointAsync(Point point) => this.InvokeAsync<Display>(point);
|
||||
|
||||
/// <summary>
|
||||
/// The display that most closely intersects the provided bounds.
|
||||
/// </summary>
|
||||
/// <param name="rectangle"></param>
|
||||
/// <returns>The display that most closely intersects the provided bounds.</returns>
|
||||
public Task<Display> GetDisplayMatchingAsync(Rectangle rectangle) => GetPropertyAsync<Display>(rectangle);
|
||||
public Task<Display> GetDisplayMatchingAsync(Rectangle rectangle) => this.InvokeAsync<Display>(rectangle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,19 +139,19 @@ public class WebContents: ApiBase
|
||||
/// Get system printers.
|
||||
/// </summary>
|
||||
/// <returns>printers</returns>
|
||||
public Task<PrinterInfo[]> GetPrintersAsync() => GetPropertyAsync<PrinterInfo[]>();
|
||||
public Task<PrinterInfo[]> GetPrintersAsync() => this.InvokeAsync<PrinterInfo[]>();
|
||||
|
||||
/// <summary>
|
||||
/// Prints window's web page.
|
||||
/// </summary>
|
||||
/// <param name="options"></param>
|
||||
/// <returns>success</returns>
|
||||
public Task<bool> PrintAsync(PrintOptions options) => GetPropertyAsync<bool>(options);
|
||||
public Task<bool> PrintAsync(PrintOptions options) => this.InvokeAsync<bool>(options);
|
||||
/// <summary>
|
||||
/// Prints window's web page.
|
||||
/// </summary>
|
||||
/// <returns>success</returns>
|
||||
public Task<bool> PrintAsync() => GetPropertyAsync<bool>(string.Empty);
|
||||
public Task<bool> PrintAsync() => this.InvokeAsync<bool>(string.Empty);
|
||||
|
||||
/// <summary>
|
||||
/// Prints window's web page as PDF with Chromium's preview printing custom
|
||||
|
||||
Reference in New Issue
Block a user