diff --git a/src/ElectronNET.API/API/ApiBase.cs b/src/ElectronNET.API/API/ApiBase.cs index ec63c743..f2b061c8 100644 --- a/src/ElectronNET.API/API/ApiBase.cs +++ b/src/ElectronNET.API/API/ApiBase.cs @@ -29,15 +29,15 @@ protected enum SocketEventNameTypes CamelCase, } - private const int PropertyTimeout = 1000; + private const int InvocationTimeout = 1000; private readonly string objectName; - private readonly ConcurrentDictionary propertyGetters; - private readonly ConcurrentDictionary propertyEventNames = new(); - private readonly ConcurrentDictionary propertyMessageNames = new(); + private readonly ConcurrentDictionary invocators; + private readonly ConcurrentDictionary invocationEventNames = new(); + private readonly ConcurrentDictionary invocationMessageNames = new(); private readonly ConcurrentDictionary methodMessageNames = new(); private static readonly ConcurrentDictionary eventContainers = new(); - private static readonly ConcurrentDictionary> AllPropertyGetters = new(); + private static readonly ConcurrentDictionary> AllInvocators = new(); private readonly object objLock = new object(); @@ -58,7 +58,7 @@ protected set protected ApiBase() { this.objectName = this.GetType().Name.LowerFirst(); - propertyGetters = AllPropertyGetters.GetOrAdd(objectName, _ => new ConcurrentDictionary()); + this.invocators = AllInvocators.GetOrAdd(this.objectName, _ => new ConcurrentDictionary()); } protected void CallMethod0([CallerMemberName] string callerName = null) @@ -113,21 +113,21 @@ protected void CallMethod3(object val1, object val2, object val3, [CallerMemberN } } - protected Task GetPropertyAsync(object arg = null, [CallerMemberName] string callerName = null) + protected Task InvokeAsync(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(this, callerName, PropertyTimeout, arg); + var getter = new Invocator(this, callerName, InvocationTimeout, arg); getter.Task().ContinueWith(_ => { lock (this.objLock) { - return this.propertyGetters.TryRemove(callerName, out var _); + return this.invocators.TryRemove(callerName, out var _); } }); @@ -135,15 +135,15 @@ protected Task GetPropertyAsync(object arg = null, [CallerMemberName] stri }).Task(); } } - + protected void AddEvent(Action value, int? id = null, [CallerMemberName] string callerName = null) { Debug.Assert(callerName != null, nameof(callerName) + " != null"); - var eventName = EventName(callerName); - - var eventKey = EventKey(eventName, id); + var eventName = this.EventName(callerName); + + var eventKey = this.EventKey(eventName, id); - lock (objLock) + lock (this.objLock) { var container = eventContainers.GetOrAdd(eventKey, _ => { @@ -156,14 +156,14 @@ protected void AddEvent(Action value, int? id = null, [CallerMemberName] string container.Register(value); } } - + protected void RemoveEvent(Action value, int? id = null, [CallerMemberName] string callerName = null) { Debug.Assert(callerName != null, nameof(callerName) + " != null"); - var eventName = EventName(callerName); - var eventKey = EventKey(eventName, id); + var eventName = this.EventName(callerName); + var eventKey = this.EventKey(eventName, id); - lock (objLock) + lock (this.objLock) { if (eventContainers.TryGetValue(eventKey, out var container) && !container.Unregister(value)) { @@ -172,15 +172,15 @@ protected void RemoveEvent(Action value, int? id = null, [CallerMemberName] stri } } } - + protected void AddEvent(Action value, int? id = null, [CallerMemberName] string callerName = null) { Debug.Assert(callerName != null, nameof(callerName) + " != null"); - - var eventName = EventName(callerName); - var eventKey = EventKey(eventName, id); - lock (objLock) + var eventName = this.EventName(callerName); + var eventKey = this.EventKey(eventName, id); + + lock (this.objLock) { var container = eventContainers.GetOrAdd(eventKey, _ => { @@ -197,10 +197,10 @@ protected void AddEvent(Action value, int? id = null, [CallerMemberName] s protected void RemoveEvent(Action value, int? id = null, [CallerMemberName] string callerName = null) { Debug.Assert(callerName != null, nameof(callerName) + " != null"); - var eventName = EventName(callerName); - var eventKey = EventKey(eventName, id); + var eventName = this.EventName(callerName); + var eventKey = this.EventKey(eventName, id); - lock (objLock) + lock (this.objLock) { if (eventContainers.TryGetValue(eventKey, out var container) && !container.Unregister(value)) { @@ -212,33 +212,33 @@ protected void RemoveEvent(Action value, int? id = null, [CallerMemberName private string EventName(string callerName) { - switch (SocketEventNameType) + switch (this.SocketEventNameType) { case SocketEventNameTypes.DashedLower: - return $"{objectName}-{callerName.ToDashedEventName()}"; + return $"{this.objectName}-{callerName.ToDashedEventName()}"; case SocketEventNameTypes.CamelCase: - return $"{objectName}-{callerName.ToCamelCaseEventName()}"; + return $"{this.objectName}-{callerName.ToCamelCaseEventName()}"; default: throw new ArgumentOutOfRangeException(); } } - + private string EventKey(string eventName, int? id) { return string.Format(CultureInfo.InvariantCulture, "{0}{1:D}", eventName, id); } - internal abstract class PropertyGetter + internal abstract class Invocator { public abstract Task Task(); } - internal class PropertyGetter : PropertyGetter + internal class Invocator : Invocator { private readonly Task tcsTask; private TaskCompletionSource 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(TaskCreationOptions.RunContinuationsAsynchronously); this.tcsTask = this.tcs.Task; @@ -249,22 +249,22 @@ public PropertyGetter(ApiBase apiBase, string callerName, int timeoutMs, object 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(); } - + 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(); @@ -289,17 +289,17 @@ public PropertyGetter(ApiBase apiBase, string callerName, int timeoutMs, object } } }); - + if (arg != null) { - _ = apiBase.Id >= 0 ? BridgeConnector.Socket.Emit(messageName, apiBase.Id, arg) : BridgeConnector.Socket.Emit(messageName, arg); + _ = apiBase.Id >= 0 ? BridgeConnector.Socket.Emit(messageName, apiBase.Id, arg) : BridgeConnector.Socket.Emit(messageName, arg); } else { - _ = apiBase.Id >= 0 ? BridgeConnector.Socket.Emit(messageName, apiBase.Id) : BridgeConnector.Socket.Emit(messageName); + _ = 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) { @@ -321,7 +321,7 @@ public override Task Task() return this.tcsTask as Task; } } - + [SuppressMessage("ReSharper", "InconsistentlySynchronizedField")] private class EventContainer { @@ -330,41 +330,41 @@ private class EventContainer private Action GetEventActionT() { - return (Action)eventActionT; + return (Action)this.eventActionT; } private void SetEventActionT(Action actionT) { - eventActionT = actionT; + this.eventActionT = actionT; } - public void OnEventAction() => eventAction?.Invoke(); + public void OnEventAction() => this.eventAction?.Invoke(); - public void OnEventActionT(T p) => GetEventActionT()?.Invoke(p); + public void OnEventActionT(T p) => this.GetEventActionT()?.Invoke(p); public void Register(Action receiver) { - eventAction += receiver; + this.eventAction += receiver; } public void Register(Action receiver) { - var actionT = GetEventActionT(); + var actionT = this.GetEventActionT(); actionT += receiver; - SetEventActionT(actionT); + this.SetEventActionT(actionT); } public bool Unregister(Action receiver) { - eventAction -= receiver; + this.eventAction -= receiver; return this.eventAction != null; } public bool Unregister(Action receiver) { - var actionT = GetEventActionT(); + var actionT = this.GetEventActionT(); actionT -= receiver; - SetEventActionT(actionT); + this.SetEventActionT(actionT); return actionT != null; } diff --git a/src/ElectronNET.API/API/App.cs b/src/ElectronNET.API/API/App.cs index 5a27e758..ee44f096 100644 --- a/src/ElectronNET.API/API/App.cs +++ b/src/ElectronNET.API/API/App.cs @@ -366,7 +366,7 @@ public Task NameAsync { get { - return this.GetPropertyAsync(); + return this.InvokeAsync(); } } @@ -501,7 +501,7 @@ public void Show() public async Task GetAppPathAsync(CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return await this.GetPropertyAsync().ConfigureAwait(false); + return await this.InvokeAsync().ConfigureAwait(false); } /// @@ -565,7 +565,7 @@ public void SetPath(PathName name, string path) public async Task GetVersionAsync(CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return await this.GetPropertyAsync().ConfigureAwait(false); + return await this.InvokeAsync().ConfigureAwait(false); } /// @@ -579,7 +579,7 @@ public async Task GetVersionAsync(CancellationToken cancellationToken = public async Task GetLocaleAsync(CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return await this.GetPropertyAsync().ConfigureAwait(false); + return await this.InvokeAsync().ConfigureAwait(false); } /// @@ -850,7 +850,7 @@ public async Task SetUserTasksAsync(UserTask[] userTasks, CancellationToke public async Task GetJumpListSettingsAsync(CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return await this.GetPropertyAsync().ConfigureAwait(false); + return await this.InvokeAsync().ConfigureAwait(false); } /// @@ -941,7 +941,7 @@ public void ReleaseSingleInstanceLock() public async Task HasSingleInstanceLockAsync(CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return await this.GetPropertyAsync().ConfigureAwait(false); + return await this.InvokeAsync().ConfigureAwait(false); } /// @@ -980,7 +980,7 @@ public void SetUserActivity(string type, object userInfo, string webpageUrl) public async Task GetCurrentActivityTypeAsync(CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return await this.GetPropertyAsync().ConfigureAwait(false); + return await this.InvokeAsync().ConfigureAwait(false); } /// @@ -1043,7 +1043,7 @@ public async Task ImportCertificateAsync(ImportCertificateOptions options, public async Task GetAppMetricsAsync(CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return await this.GetPropertyAsync().ConfigureAwait(false); + return await this.InvokeAsync().ConfigureAwait(false); } /// @@ -1055,7 +1055,7 @@ public async Task GetAppMetricsAsync(CancellationToken cancella public async Task GetGpuFeatureStatusAsync(CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return await this.GetPropertyAsync().ConfigureAwait(false); + return await this.InvokeAsync().ConfigureAwait(false); } /// @@ -1090,7 +1090,7 @@ public async Task SetBadgeCountAsync(int count, CancellationToken cancella public async Task GetBadgeCountAsync(CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return await this.GetPropertyAsync().ConfigureAwait(false); + return await this.InvokeAsync().ConfigureAwait(false); } /// @@ -1105,7 +1105,7 @@ public async Task GetBadgeCountAsync(CancellationToken cancellationToken = public async Task IsUnityRunningAsync(CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return await this.GetPropertyAsync().ConfigureAwait(false); + return await this.InvokeAsync().ConfigureAwait(false); } /// @@ -1166,7 +1166,7 @@ public void SetLoginItemSettings(LoginSettings loginSettings) public async Task IsAccessibilitySupportEnabledAsync(CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return await this.GetPropertyAsync().ConfigureAwait(false); + return await this.InvokeAsync().ConfigureAwait(false); } /// diff --git a/src/ElectronNET.API/API/AutoUpdater.cs b/src/ElectronNET.API/API/AutoUpdater.cs index 0b5fd75f..639cd8ca 100644 --- a/src/ElectronNET.API/API/AutoUpdater.cs +++ b/src/ElectronNET.API/API/AutoUpdater.cs @@ -23,7 +23,7 @@ public bool AutoDownload { get { - return Task.Run(() => GetPropertyAsync()).Result; + return Task.Run(() => this.InvokeAsync()).Result; } set { @@ -40,7 +40,7 @@ public bool AutoInstallOnAppQuit { get { - return Task.Run(() => GetPropertyAsync()).Result; + return Task.Run(() => this.InvokeAsync()).Result; } set { @@ -58,7 +58,7 @@ public bool AllowPrerelease { get { - return Task.Run(() => GetPropertyAsync()).Result; + return Task.Run(() => this.InvokeAsync()).Result; } set { @@ -74,7 +74,7 @@ public bool FullChangelog { get { - return Task.Run(() => GetPropertyAsync()).Result; + return Task.Run(() => this.InvokeAsync()).Result; } set { @@ -91,7 +91,7 @@ public bool AllowDowngrade { get { - return Task.Run(() => GetPropertyAsync()).Result; + return Task.Run(() => this.InvokeAsync()).Result; } set { @@ -106,7 +106,7 @@ public string UpdateConfigPath { get { - return Task.Run(() => GetPropertyAsync()).Result; + return Task.Run(() => this.InvokeAsync()).Result; } } @@ -117,7 +117,7 @@ public Task CurrentVersionAsync { get { - return Task.Run(() => GetPropertyAsync()); + return Task.Run(() => this.InvokeAsync()); } } @@ -142,7 +142,7 @@ public Task ChannelAsync { get { - return Task.Run(() => GetPropertyAsync()); + return Task.Run(() => this.InvokeAsync()); } } @@ -165,7 +165,7 @@ public Task> RequestHeadersAsync { get { - return Task.Run(() => GetPropertyAsync>()); + return Task.Run(() => this.InvokeAsync>()); } } diff --git a/src/ElectronNET.API/API/BrowserView.cs b/src/ElectronNET.API/API/BrowserView.cs index 479d9712..32030736 100644 --- a/src/ElectronNET.API/API/BrowserView.cs +++ b/src/ElectronNET.API/API/BrowserView.cs @@ -30,7 +30,7 @@ public Rectangle Bounds { get { - return Task.Run(() => GetPropertyAsync()).Result; + return Task.Run(() => this.InvokeAsync()).Result; } set { diff --git a/src/ElectronNET.API/API/BrowserWindow.cs b/src/ElectronNET.API/API/BrowserWindow.cs index f4e7529f..7cb99386 100644 --- a/src/ElectronNET.API/API/BrowserWindow.cs +++ b/src/ElectronNET.API/API/BrowserWindow.cs @@ -313,13 +313,13 @@ internal BrowserWindow(int id) /// Whether the window is focused. /// /// - public Task IsFocusedAsync() => this.GetPropertyAsync(); + public Task IsFocusedAsync() => this.InvokeAsync(); /// /// Whether the window is destroyed. /// /// - public Task IsDestroyedAsync() => this.GetPropertyAsync(); + public Task IsDestroyedAsync() => this.InvokeAsync(); /// /// Shows and gives focus to the window. @@ -340,13 +340,13 @@ internal BrowserWindow(int id) /// Whether the window is visible to the user. /// /// - public Task IsVisibleAsync() => this.GetPropertyAsync(); + public Task IsVisibleAsync() => this.InvokeAsync(); /// /// Whether current window is a modal window. /// /// - public Task IsModalAsync() => this.GetPropertyAsync(); + public Task IsModalAsync() => this.InvokeAsync(); /// /// Maximizes the window. This will also show (but not focus) the window if it isn’t being displayed already. @@ -362,7 +362,7 @@ internal BrowserWindow(int id) /// Whether the window is maximized. /// /// - public Task IsMaximizedAsync() => this.GetPropertyAsync(); + public Task IsMaximizedAsync() => this.InvokeAsync(); /// /// Minimizes the window. On some platforms the minimized window will be shown in the Dock. @@ -378,7 +378,7 @@ internal BrowserWindow(int id) /// Whether the window is minimized. /// /// - public Task IsMinimizedAsync() => this.GetPropertyAsync(); + public Task IsMinimizedAsync() => this.InvokeAsync(); /// /// Sets whether the window should be in fullscreen mode. @@ -390,7 +390,7 @@ internal BrowserWindow(int id) /// Whether the window is in fullscreen mode. /// /// - public Task IsFullScreenAsync() => this.GetPropertyAsync(); + public Task IsFullScreenAsync() => this.InvokeAsync(); /// /// This will make a window maintain an aspect ratio. The extra size allows a developer to have space, @@ -466,7 +466,7 @@ public void SetAspectRatio(int aspectRatio, Size extraSize) => /// Gets the bounds asynchronous. /// /// - public Task GetBoundsAsync() => this.GetPropertyAsync(); + public Task GetBoundsAsync() => this.InvokeAsync(); /// /// Resizes and moves the window’s client area (e.g. the web page) to the supplied bounds. @@ -485,7 +485,7 @@ public void SetAspectRatio(int aspectRatio, Size extraSize) => /// Gets the content bounds asynchronous. /// /// - public Task GetContentBoundsAsync() => this.GetPropertyAsync(); + public Task GetContentBoundsAsync() => this.InvokeAsync(); /// /// Resizes the window to width and height. @@ -506,7 +506,7 @@ public void SetAspectRatio(int aspectRatio, Size extraSize) => /// Contains the window’s width and height. /// /// - public Task GetSizeAsync() => this.GetPropertyAsync(); + public Task GetSizeAsync() => this.InvokeAsync(); /// /// Resizes the window’s client area (e.g. the web page) to width and height. @@ -527,7 +527,7 @@ public void SetAspectRatio(int aspectRatio, Size extraSize) => /// Contains the window’s client area’s width and height. /// /// - public Task GetContentSizeAsync() => this.GetPropertyAsync(); + public Task GetContentSizeAsync() => this.InvokeAsync(); /// /// Sets the minimum size of window to width and height. @@ -540,7 +540,7 @@ public void SetAspectRatio(int aspectRatio, Size extraSize) => /// Contains the window’s minimum width and height. /// /// - public Task GetMinimumSizeAsync() => this.GetPropertyAsync(); + public Task GetMinimumSizeAsync() => this.InvokeAsync(); /// /// Sets the maximum size of window to width and height. @@ -553,7 +553,7 @@ public void SetAspectRatio(int aspectRatio, Size extraSize) => /// Contains the window’s maximum width and height. /// /// - public Task GetMaximumSizeAsync() => this.GetPropertyAsync(); + public Task GetMaximumSizeAsync() => this.InvokeAsync(); /// /// Sets whether the window can be manually resized by user. @@ -565,7 +565,7 @@ public void SetAspectRatio(int aspectRatio, Size extraSize) => /// Whether the window can be manually resized by user. /// /// - public Task IsResizableAsync() => this.GetPropertyAsync(); + public Task IsResizableAsync() => this.InvokeAsync(); /// /// Sets whether the window can be moved by user. On Linux does nothing. @@ -579,7 +579,7 @@ public void SetAspectRatio(int aspectRatio, Size extraSize) => /// On Linux always returns true. /// /// On Linux always returns true. - public Task IsMovableAsync() => this.GetPropertyAsync(); + public Task IsMovableAsync() => this.InvokeAsync(); /// /// Sets whether the window can be manually minimized by user. On Linux does nothing. @@ -593,7 +593,7 @@ public void SetAspectRatio(int aspectRatio, Size extraSize) => /// On Linux always returns true. /// /// On Linux always returns true. - public Task IsMinimizableAsync() => this.GetPropertyAsync(); + public Task IsMinimizableAsync() => this.InvokeAsync(); /// /// Sets whether the window can be manually maximized by user. On Linux does nothing. @@ -607,7 +607,7 @@ public void SetAspectRatio(int aspectRatio, Size extraSize) => /// On Linux always returns true. /// /// On Linux always returns true. - public Task IsMaximizableAsync() => this.GetPropertyAsync(); + public Task IsMaximizableAsync() => this.InvokeAsync(); /// /// Sets whether the maximize/zoom window button toggles fullscreen mode or maximizes the window. @@ -619,7 +619,7 @@ public void SetAspectRatio(int aspectRatio, Size extraSize) => /// Whether the maximize/zoom window button toggles fullscreen mode or maximizes the window. /// /// - public Task IsFullScreenableAsync() => this.GetPropertyAsync(); + public Task IsFullScreenableAsync() => this.InvokeAsync(); /// /// Sets whether the window can be manually closed by user. On Linux does nothing. @@ -633,7 +633,7 @@ public void SetAspectRatio(int aspectRatio, Size extraSize) => /// On Linux always returns true. /// /// On Linux always returns true. - public Task IsClosableAsync() => this.GetPropertyAsync(); + public Task IsClosableAsync() => this.InvokeAsync(); /// /// Sets whether the window should show always on top of other windows. @@ -671,7 +671,7 @@ public void SetAspectRatio(int aspectRatio, Size extraSize) => /// Whether the window is always on top of other windows. /// /// - public Task IsAlwaysOnTopAsync() => this.GetPropertyAsync(); + public Task IsAlwaysOnTopAsync() => this.InvokeAsync(); /// /// Moves window to the center of the screen. @@ -721,7 +721,7 @@ private bool isWindows10() /// Contains the window’s current position. /// /// - public Task GetPositionAsync() => this.GetPropertyAsync(); + public Task GetPositionAsync() => this.InvokeAsync(); /// /// Changes the title of native window to title. @@ -735,7 +735,7 @@ private bool isWindows10() /// Note: The title of web page can be different from the title of the native window. /// /// - public Task GetTitleAsync() => this.GetPropertyAsync(); + public Task GetTitleAsync() => this.InvokeAsync(); /// /// Changes the attachment point for sheets on macOS. @@ -776,13 +776,13 @@ private bool isWindows10() /// Whether the window is in kiosk mode. /// /// - public Task IsKioskAsync() => this.GetPropertyAsync(); + public Task IsKioskAsync() => this.InvokeAsync(); /// /// Returns the native type of the handle is HWND on Windows, NSView* on macOS, and Window (unsigned long) on Linux. /// /// string of the native handle obtained, HWND on Windows, NSView* on macOS, and Window (unsigned long) on Linux. - public Task GetNativeWindowHandle() => this.GetPropertyAsync(); + public Task GetNativeWindowHandle() => this.InvokeAsync(); /// /// Sets the pathname of the file the window represents, @@ -795,7 +795,7 @@ private bool isWindows10() /// The pathname of the file the window represents. /// /// - public Task GetRepresentedFilenameAsync() => this.GetPropertyAsync(); + public Task GetRepresentedFilenameAsync() => this.InvokeAsync(); /// /// Specifies whether the window’s document has been edited, @@ -808,7 +808,7 @@ private bool isWindows10() /// Whether the window’s document has been edited. /// /// - public Task IsDocumentEditedAsync() => this.GetPropertyAsync(); + public Task IsDocumentEditedAsync() => this.InvokeAsync(); /// /// Focuses the on web view. @@ -920,7 +920,7 @@ public void SetProgressBar(double progress, ProgressBarOptions progressBarOption /// On Windows and Linux always returns true. /// /// - public Task HasShadowAsync() => this.GetPropertyAsync(); + public Task HasShadowAsync() => this.InvokeAsync(); /// /// Gets the thumbar buttons. @@ -1012,7 +1012,7 @@ public Task SetThumbarButtonsAsync(ThumbarButton[] thumbarButtons) /// Whether menu bar automatically hides itself. /// /// - public Task IsMenuBarAutoHideAsync() => this.GetPropertyAsync(); + public Task IsMenuBarAutoHideAsync() => this.InvokeAsync(); /// /// Sets whether the menu bar should be visible. If the menu bar is auto-hide, @@ -1025,7 +1025,7 @@ public Task SetThumbarButtonsAsync(ThumbarButton[] thumbarButtons) /// Whether the menu bar is visible. /// /// - public Task IsMenuBarVisibleAsync() => this.GetPropertyAsync(); + public Task IsMenuBarVisibleAsync() => this.InvokeAsync(); /// /// Sets whether the window should be visible on all workspaces. @@ -1041,7 +1041,7 @@ public Task SetThumbarButtonsAsync(ThumbarButton[] thumbarButtons) /// Note: This API always returns false on Windows. /// /// - public Task IsVisibleOnAllWorkspacesAsync() => this.GetPropertyAsync(); + public Task IsVisibleOnAllWorkspacesAsync() => this.InvokeAsync(); /// /// Makes the window ignore all mouse events. @@ -1090,7 +1090,7 @@ public void SetParentWindow(BrowserWindow parent) /// public async Task GetParentWindowAsync() { - var browserWindowId = await this.GetPropertyAsync().ConfigureAwait(false); + var browserWindowId = await this.InvokeAsync().ConfigureAwait(false); var browserWindow = Electron.WindowManager.BrowserWindows.ToList().Single(x => x.Id == browserWindowId); return browserWindow; } @@ -1101,7 +1101,7 @@ public async Task GetParentWindowAsync() /// public async Task> GetChildWindowsAsync() { - var browserWindowIds = await this.GetPropertyAsync().ConfigureAwait(false); + var browserWindowIds = await this.InvokeAsync().ConfigureAwait(false); var browserWindows = new List(); foreach (var id in browserWindowIds) diff --git a/src/ElectronNET.API/API/Clipboard.cs b/src/ElectronNET.API/API/Clipboard.cs index 5d067f6a..1a011be9 100644 --- a/src/ElectronNET.API/API/Clipboard.cs +++ b/src/ElectronNET.API/API/Clipboard.cs @@ -45,7 +45,7 @@ internal static Clipboard Instance /// /// /// The content in the clipboard as plain text. - public Task ReadTextAsync(string type = "") => GetPropertyAsync(type); + public Task ReadTextAsync(string type = "") => this.InvokeAsync(type); /// /// Writes the text into the clipboard as plain text. @@ -62,7 +62,7 @@ public void WriteText(string text, string type = "") /// /// /// - public Task ReadHTMLAsync(string type = "") => GetPropertyAsync(type); + public Task ReadHTMLAsync(string type = "") => this.InvokeAsync(type); /// /// Writes markup to the clipboard. @@ -79,7 +79,7 @@ public void WriteHTML(string markup, string type = "") /// /// /// - public Task ReadRTFAsync(string type = "") => GetPropertyAsync(type); + public Task ReadRTFAsync(string type = "") => this.InvokeAsync(type); /// /// Writes the text into the clipboard in RTF. @@ -97,7 +97,7 @@ public void WriteRTF(string text, string type = "") /// be empty strings when the bookmark is unavailable. /// /// - public Task ReadBookmarkAsync() => GetPropertyAsync(); + public Task ReadBookmarkAsync() => this.InvokeAsync(); /// /// Writes the title and url into the clipboard as a bookmark. @@ -120,7 +120,7 @@ public void WriteBookmark(string title, string url, string type = "") /// find pasteboard whenever the application is activated. /// /// - public Task ReadFindTextAsync() => GetPropertyAsync(); + public Task ReadFindTextAsync() => this.InvokeAsync(); /// /// macOS: Writes the text into the find pasteboard as plain text. This method uses @@ -146,7 +146,7 @@ public void Clear(string type = "") /// /// /// - public Task AvailableFormatsAsync(string type = "") => GetPropertyAsync(type); + public Task AvailableFormatsAsync(string type = "") => this.InvokeAsync(type); /// /// Writes data to the clipboard. @@ -163,7 +163,7 @@ public void Write(Data data, string type = "") /// /// /// - public Task ReadImageAsync(string type = "") => GetPropertyAsync(type); + public Task ReadImageAsync(string type = "") => this.InvokeAsync(type); /// /// Writes an image to the clipboard. diff --git a/src/ElectronNET.API/API/NativeTheme.cs b/src/ElectronNET.API/API/NativeTheme.cs index c817b9d8..5e7c9915 100644 --- a/src/ElectronNET.API/API/NativeTheme.cs +++ b/src/ElectronNET.API/API/NativeTheme.cs @@ -107,26 +107,26 @@ public void SetThemeSource(ThemeSourceMode themeSourceMode) /// A property that can be , or . It is used to override () and /// supercede the value that Chromium has chosen to use internally. /// - public Task GetThemeSourceAsync() => GetPropertyAsync(); + public Task GetThemeSourceAsync() => this.InvokeAsync(); /// /// A 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 . /// - public Task ShouldUseDarkColorsAsync() => GetPropertyAsync(); + public Task ShouldUseDarkColorsAsync() => this.InvokeAsync(); /// /// A for if the OS / Chromium currently has high-contrast mode enabled or is /// being instructed to show a high-contrast UI. /// - public Task ShouldUseHighContrastColorsAsync() => GetPropertyAsync(); + public Task ShouldUseHighContrastColorsAsync() => this.InvokeAsync(); /// /// A for if the OS / Chromium currently has an inverted color scheme or is /// being instructed to use an inverted color scheme. /// - public Task ShouldUseInvertedColorSchemeAsync() => GetPropertyAsync(); + public Task ShouldUseInvertedColorSchemeAsync() => this.InvokeAsync(); /// /// Emitted when something in the underlying NativeTheme has changed. This normally means that either the value of , diff --git a/src/ElectronNET.API/API/Notification.cs b/src/ElectronNET.API/API/Notification.cs index aaa0c479..fe17bf94 100644 --- a/src/ElectronNET.API/API/Notification.cs +++ b/src/ElectronNET.API/API/Notification.cs @@ -116,6 +116,6 @@ private static void GenerateIDsForDefinedActions(NotificationOptions notificatio /// Whether or not desktop notifications are supported on the current system. /// /// - public Task IsSupportedAsync() => GetPropertyAsync(); + public Task IsSupportedAsync() => this.InvokeAsync(); } } diff --git a/src/ElectronNET.API/API/Process.cs b/src/ElectronNET.API/API/Process.cs index 328b0074..3edf1b56 100644 --- a/src/ElectronNET.API/API/Process.cs +++ b/src/ElectronNET.API/API/Process.cs @@ -44,7 +44,7 @@ internal static Process Instance /// The process.execPath property returns the absolute pathname of the executable that /// started the Node.js process. Symbolic links, if any, are resolved. /// - public Task ExecPathAsync => GetPropertyAsync(); + public Task ExecPathAsync => this.InvokeAsync(); /// /// The process.argv property returns an array containing the command-line arguments passed @@ -53,56 +53,56 @@ internal static Process Instance /// will be the path to the JavaScript file being executed. The remaining elements will be /// any additional command-line arguments /// - public Task ArgvAsync => GetPropertyAsync(); + public Task ArgvAsync => this.InvokeAsync(); /// /// The process.execPath property returns the absolute pathname of the executable that /// started the Node.js process. Symbolic links, if any, are resolved. /// - public Task TypeAsync => GetPropertyAsync(); + public Task TypeAsync => this.InvokeAsync(); /// /// The process.versions property returns an object listing the version strings of /// chrome and electron. /// - public Task VersionsAsync => GetPropertyAsync(); + public Task VersionsAsync => this.InvokeAsync(); /// /// 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. /// - public Task DefaultAppAsync => GetPropertyAsync(); + public Task DefaultAppAsync => this.InvokeAsync(); /// /// 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 /// - public Task IsMainFrameAsync => GetPropertyAsync(); + public Task IsMainFrameAsync => this.InvokeAsync(); /// /// A String representing the path to the resources directory. /// - public Task ResourcesPathAsync => GetPropertyAsync(); + public Task ResourcesPathAsync => this.InvokeAsync(); /// /// 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. /// - public Task UpTimeAsync => GetPropertyAsync(); + public Task UpTimeAsync => this.InvokeAsync(); /// /// The PID of the electron process /// - public Task PidAsync => GetPropertyAsync(); + public Task PidAsync => this.InvokeAsync(); /// /// The operating system CPU architecture for which the Node.js binary was compiled /// - public Task ArchAsync => GetPropertyAsync(); + public Task ArchAsync => this.InvokeAsync(); /// /// A string identifying the operating system platform on which the Node.js process is running /// - public Task PlatformAsync => GetPropertyAsync(); + public Task PlatformAsync => this.InvokeAsync(); } } diff --git a/src/ElectronNET.API/API/Screen.cs b/src/ElectronNET.API/API/Screen.cs index 8c2b5cb0..17bf13f0 100644 --- a/src/ElectronNET.API/API/Screen.cs +++ b/src/ElectronNET.API/API/Screen.cs @@ -101,37 +101,37 @@ internal static Screen Instance /// The current absolute position of the mouse pointer. /// /// - public Task GetCursorScreenPointAsync() => GetPropertyAsync(); + public Task GetCursorScreenPointAsync() => this.InvokeAsync(); /// /// macOS: The height of the menu bar in pixels. /// /// The height of the menu bar in pixels. - public Task GetMenuBarWorkAreaAsync() => GetPropertyAsync(); + public Task GetMenuBarWorkAreaAsync() => this.InvokeAsync(); /// /// The primary display. /// /// - public Task GetPrimaryDisplayAsync() => GetPropertyAsync(); + public Task GetPrimaryDisplayAsync() => this.InvokeAsync(); /// /// An array of displays that are currently available. /// /// An array of displays that are currently available. - public Task GetAllDisplaysAsync() => GetPropertyAsync(); + public Task GetAllDisplaysAsync() => this.InvokeAsync(); /// /// The display nearest the specified point. /// /// The display nearest the specified point. - public Task GetDisplayNearestPointAsync(Point point) => GetPropertyAsync(point); + public Task GetDisplayNearestPointAsync(Point point) => this.InvokeAsync(point); /// /// The display that most closely intersects the provided bounds. /// /// /// The display that most closely intersects the provided bounds. - public Task GetDisplayMatchingAsync(Rectangle rectangle) => GetPropertyAsync(rectangle); + public Task GetDisplayMatchingAsync(Rectangle rectangle) => this.InvokeAsync(rectangle); } } diff --git a/src/ElectronNET.API/API/WebContents.cs b/src/ElectronNET.API/API/WebContents.cs index 761bfed4..5c598d2f 100644 --- a/src/ElectronNET.API/API/WebContents.cs +++ b/src/ElectronNET.API/API/WebContents.cs @@ -139,19 +139,19 @@ public void OpenDevTools(OpenDevToolsOptions openDevToolsOptions) /// Get system printers. /// /// printers - public Task GetPrintersAsync() => GetPropertyAsync(); + public Task GetPrintersAsync() => this.InvokeAsync(); /// /// Prints window's web page. /// /// /// success - public Task PrintAsync(PrintOptions options) => GetPropertyAsync(options); + public Task PrintAsync(PrintOptions options) => this.InvokeAsync(options); /// /// Prints window's web page. /// /// success - public Task PrintAsync() => GetPropertyAsync(string.Empty); + public Task PrintAsync() => this.InvokeAsync(string.Empty); /// /// Prints window's web page as PDF with Chromium's preview printing custom