mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-14 13:44:47 +00:00
Aanpassingen autoupdate & async code
This commit is contained in:
@@ -407,6 +407,27 @@ namespace ElectronNET.API
|
||||
/// which will be preferred over name by Electron.
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
[Obsolete("Use the asynchronous version NameAsync instead")]
|
||||
get
|
||||
{
|
||||
return AsyncHelper.RunSync(async () => await NameAsync);
|
||||
}
|
||||
set
|
||||
{
|
||||
BridgeConnector.Socket.Emit("appSetName", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="string"/> property that indicates the current application's name, which is the name in the
|
||||
/// application's package.json file.
|
||||
///
|
||||
/// Usually the name field of package.json is a short lowercase name, according to the npm modules spec. You
|
||||
/// should usually also specify a productName field, which is your application's full capitalized name, and
|
||||
/// which will be preferred over name by Electron.
|
||||
/// </summary>
|
||||
public Task<string> NameAsync
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -423,14 +444,34 @@ namespace ElectronNET.API
|
||||
BridgeConnector.Socket.Emit("appGetName");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}).Result;
|
||||
}
|
||||
set
|
||||
{
|
||||
BridgeConnector.Socket.Emit("appSetName", value);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<string> GetName()
|
||||
|
||||
{
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
BridgeConnector.Socket.On("appGetNameCompleted", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("appGetNameCompleted");
|
||||
taskCompletionSource.SetResult((string)result);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("appGetName");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
internal App()
|
||||
{
|
||||
CommandLine = new CommandLine();
|
||||
@@ -1479,6 +1520,27 @@ namespace ElectronNET.API
|
||||
/// is used.
|
||||
/// </summary>
|
||||
public string UserAgentFallback
|
||||
{
|
||||
[Obsolete("Use the asynchronous version UserAgentFallbackAsync instead")]
|
||||
get
|
||||
{
|
||||
return AsyncHelper.RunSync(async () => await UserAgentFallbackAsync);
|
||||
}
|
||||
set
|
||||
{
|
||||
BridgeConnector.Socket.Emit("appSetUserAgentFallback", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="string"/> which is the user agent string Electron will use as a global fallback.
|
||||
/// <para/>
|
||||
/// This is the user agent that will be used when no user agent is set at the webContents or
|
||||
/// session level. It is useful for ensuring that your entire app has the same user agent. Set to a
|
||||
/// custom value as early as possible in your app's initialization to ensure that your overridden value
|
||||
/// is used.
|
||||
/// </summary>
|
||||
public Task<string> UserAgentFallbackAsync
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -1487,19 +1549,15 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
BridgeConnector.Socket.On("appGetUserAgentFallbackCompleted", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("appGetUserAgentFallbackCompleted");
|
||||
taskCompletionSource.SetResult((string)result);
|
||||
});
|
||||
{
|
||||
BridgeConnector.Socket.Off("appGetUserAgentFallbackCompleted");
|
||||
taskCompletionSource.SetResult((string)result);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("appGetUserAgentFallback");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}).Result;
|
||||
}
|
||||
set
|
||||
{
|
||||
BridgeConnector.Socket.Emit("appSetUserAgentFallback", value);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user