* Ground work for NET9 UWP switch. * Add launch settings for Wino.Mail * Added new test WAP project * fix platforms in slnx solution * ManagePackageVersionsCentrally set default * Fixing assets and couple issues with the new packaging project. * Add back markdown * Fix nuget warnings * FIx error in WAP about build tools * Add build.props with default language preview * Some AOT compilation progress. * More AOT stuff. * Remove deprecated protocol auth activation handler. * Fix remaining protocol handler for google auth. * Even more AOT * More more AOT fixes * Fix a few more AOT warnings * Fix signature editor AOT * Fix composer and renderer AOT JSON * Outlook Sync AOT * Fixing bundle generation and package signing. --------- Co-authored-by: Burak Kaan Köse <bkaankose@outlook.com>
33 lines
1.2 KiB
C#
33 lines
1.2 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Wino.Core.UWP.Extensions;
|
|
|
|
public static class WebViewExtensions
|
|
{
|
|
/// <summary>
|
|
/// Executes a script function in the WebView2 control.
|
|
/// </summary>
|
|
/// <param name="isChromiumDisposed">Weird parameter that needed in mailRendering page. TODO: should be reconsidered.</param>
|
|
/// <param name="parameters">Parameters should be serialized to json</param>
|
|
public static async Task<string> ExecuteScriptFunctionAsync(this Microsoft.UI.Xaml.Controls.WebView2 Chromium, string functionName, bool isChromiumDisposed = false, params string[] parameters)
|
|
{
|
|
string script = functionName + "(" + string.Join(", ", parameters) + ");";
|
|
|
|
return isChromiumDisposed ? string.Empty : await Chromium.ExecuteScriptAsync(script);
|
|
}
|
|
|
|
public static async Task<string> ExecuteScriptFunctionSafeAsync(this Microsoft.UI.Xaml.Controls.WebView2 Chromium, string functionName, params string[] parameters)
|
|
{
|
|
if (Chromium == null) return string.Empty;
|
|
|
|
try
|
|
{
|
|
return await Chromium.ExecuteScriptFunctionAsync(functionName, parameters: parameters);
|
|
}
|
|
catch { }
|
|
|
|
return string.Empty;
|
|
}
|
|
}
|