internal static Task Send(MethodProxy methodProxy) { string csharpProxy = BridgeSerializer.Serialize(methodProxy); BlazorMobileComponent.GetJSRuntime().InvokeAsync <bool>("contextBridgeSend", csharpProxy); return(Task.CompletedTask); }
void AlertSignalNameHandler(Page sender, AlertArguments arguments) { //Electron documentation about dialog: https://github.com/electron/electron/blob/v5.0.10/docs/api/dialog.md var applicationRef = DotNetObjectReference.Create(new ElectronBridge(this)); var alertRef = DotNetObjectReference.Create(arguments); BlazorMobileComponent.GetJSRuntime().InvokeAsync <bool>("BlazorMobileElectron.AlertDialog", applicationRef, alertRef, arguments.Title, arguments.Message, arguments.Accept, arguments.Cancel); }
public static async Task Send(MethodProxy methodProxy) { string csharpProxy = BridgeSerializer.Serialize(methodProxy); InternalHelper.SetTimeout(async() => { await BlazorMobileComponent.GetJSRuntime().InvokeAsync <bool>("contextBridgeSend", csharpProxy); }, 100); }
/// <summary> /// Add a display:none attribute to the selected element with the corresponding id attribute. /// This is mainly used for hidding the extra placeholder used during BlazorMobile loading, after it has finished /// </summary> /// <param name="elementId"></param> public static void HideElementById(string elementId) { var runtime = BlazorMobileComponent.GetJSRuntime(); if (runtime == null) { Console.WriteLine("Cannot call HideElementById, JSRuntime interop is not yet ready"); return; } try { BlazorMobileComponent.GetJSRuntime().InvokeVoidAsync("BlazorXamarin.HideElementById", elementId); } catch (Exception) { } }
public static bool ReceiveFromXamarin(string methodProxyJson, bool socketSuccess) { if (string.IsNullOrEmpty(methodProxyJson)) { return(false); } try { ClientMethodProxy resultProxy = BridgeSerializer.Deserialize <ClientMethodProxy>(ref methodProxyJson); BlazorMobileComponent.GetJSRuntime().InvokeAsync <bool>("contextBridgeSendClient", resultProxy.InteropAssembly, resultProxy.InteropMethod, resultProxy.InteropParameters); return(true); } catch (Exception ex) { ConsoleHelper.WriteException(ex); return(false); } }