using Microsoft.JSInterop; using System; using System.Threading.Tasks; namespace Oqtane.Shared { public class Interop { private readonly IJSRuntime jsRuntime; public Interop(IJSRuntime jsRuntime) { this.jsRuntime = jsRuntime; } public Task SetCookie(string name, string value, int days) { try { jsRuntime.InvokeAsync( "interop.setCookie", name, value, days); return Task.CompletedTask; } catch { return Task.CompletedTask; } } public Task GetCookie(string name) { try { return jsRuntime.InvokeAsync( "interop.getCookie", name); } catch { return Task.FromResult(string.Empty); } } public Task AddCSS(string filename) { try { jsRuntime.InvokeAsync( "interop.addCSS", filename); return Task.CompletedTask; } catch { return Task.CompletedTask; } } public Task GetElementByName(string name) { try { return jsRuntime.InvokeAsync( "interop.getElementByName", name); } catch { return Task.FromResult(string.Empty); } } public Task SubmitForm(string path, object fields) { try { jsRuntime.InvokeAsync( "interop.submitForm", path, fields); return Task.CompletedTask; } catch { return Task.CompletedTask; } } } }