public static ValueTask StartVideoAsync( IJSRuntime?jSRuntime, string deviceId, string selector) => jSRuntime?.InvokeVoidAsync( "videoInterop.startVideo", deviceId, selector) ?? new ValueTask();
/// <summary> /// 根据指定菜单 ID 激活侧边栏菜单项 /// </summary> /// <param name="jsRuntime"></param> /// <param name="menuId"></param> /// <returns></returns> public static void ActiveMenu(this IJSRuntime?jsRuntime, string?menuId) { if (!string.IsNullOrEmpty(menuId) && jsRuntime != null) { jsRuntime.InvokeVoidAsync("$.activeMenu", menuId); } }
public static ValueTask <bool> CreateOrJoinRoomAsync( this IJSRuntime?jsRuntime, string roomName, string token) => jsRuntime?.InvokeAsync <bool>( "videoInterop.createOrJoinRoom", roomName, token) ?? new ValueTask <bool>(false);
/// <summary> /// 弹出 Tooltip 组件 /// </summary> /// <param name="jsRuntime"></param> /// <param name="id"></param> /// <param name="method"></param> /// <param name="popoverType"></param> /// <param name="title"></param> /// <param name="content"></param> /// <param name="html"></param> public static void Tooltip(this IJSRuntime?jsRuntime, string?id, string method = "", PopoverType popoverType = PopoverType.Tooltip, string?title = "", string?content = "", bool html = false) { if (!string.IsNullOrEmpty(id)) { jsRuntime.InvokeVoidAsync(popoverType == PopoverType.Tooltip ? "$.tooltip" : "$.popover", id, method, title, content, html); } }
/// <summary> /// Invoke $.run 方法 /// </summary> /// <param name="jsRuntime"></param> /// <param name="id"></param> /// <param name="func"></param> /// <param name="args"></param> public static void InvokeRun(this IJSRuntime?jsRuntime, string?id, string func, params string[] args) { if (!string.IsNullOrEmpty(id)) { var para = args != null?string.Join(",", args.Select(p => $"\"{p}\"")) : ""; jsRuntime?.InvokeVoidAsync("$.run", $"$('#{id}').{func}({para})"); } }
/// <summary> /// 调用 JSInvoke 方法 /// </summary> /// <param name="jsRuntime">IJSRuntime 实例</param> /// <param name="el">Element 实例或者组件 Id</param> /// <param name="ref">DotNetObjectReference 实例</param> /// <param name="func">Javascript 方法</param> /// <param name="args">Javascript 参数</param> public static void Invoke(this IJSRuntime?jsRuntime, object?el = null, string?func = null, object? @ref = null, params object[] args) { var paras = new List <object>(); if (el != null) { paras.Add(el); } if (@ref != null) { paras.Add(@ref); } if (args != null) { paras.AddRange(args); } jsRuntime?.InvokeVoidAsync($"$.{func}", paras.ToArray()); }
internal StructureInstance(Structure <T> structure, IJSRuntime?jsRuntime) { Structure = structure; JSRuntime = jsRuntime; ValidationState = new ValidationState <T>(this); _memberInstances = new Dictionary <string, IMemberInstance <T> >(); foreach (IMember <T> member in structure.AllMembers()) { IMemberInstance <T> instance = member.Instantiate(); instance.OnInput += ValidationState.Invalidate; instance.OnValueUpdateUntyped += (v, m, mv) => { OnMemberValueUpdate?.Invoke(v, m, mv); ValidationState.ValidateStructure(v); }; _memberInstances[member.ID] = instance; } }
/// <summary> /// 弹出 Toast 组件 /// </summary> /// <param name="jSRuntime"></param> /// <param name="title"></param> /// <param name="message"></param> /// <param name="cate"></param> public static void ShowToast(this IJSRuntime?jSRuntime, string title, string message, ToastCategory cate) => jSRuntime?.InvokeVoidAsync("$.showToast", title, message, cate.ToString());
public BlazorStateMachineResolver(SessionStorage sessionStorage, IJSRuntime jsRuntime) : this(sessionStorage) { _jsRuntime = jsRuntime ?? throw new ArgumentException("The value cannot be null", nameof(jsRuntime)); }
/// <summary> /// 弹出 Toast 组件 /// </summary> /// <param name="jSRuntime"></param> public static void ShowToast(this IJSRuntime?jSRuntime) => jSRuntime.InvokeVoidAsync("$.showToast");
/// <summary> /// 修复 Modal 组件 /// </summary> /// <param name="jSRuntime"></param> public static void InitToast(this IJSRuntime?jSRuntime) => jSRuntime.InvokeVoidAsync("$.initToast");
/// <summary> /// 初始化 Table 组件 /// </summary> /// <param name="jSRuntime"></param> /// <param name="id"></param> /// <param name="firstRender"></param> public static void InitTableAsync(this IJSRuntime?jSRuntime, string id, bool firstRender) => jSRuntime?.InvokeVoidAsync("$.initTable", id, firstRender);
public ValueTask <object> SetItemAsync(string key, string?data, IJSRuntime?jsRuntime) { return(jsRuntime.InvokeAsync <object>($"{_fullTypeName}.SetItem", key, data)); }
public void RemoveItem(string key, IJSRuntime?jsRuntime) { jsRuntime.InvokeAsync <object>($"{_fullTypeName}.RemoveItem", key, key); }
public ValueTask <object> RemoveItemAsync(string key, IJSRuntime?jsRuntime) { return(jsRuntime.InvokeAsync <object>($"{_fullTypeName}.RemoveItem", key)); }
public ValueTask <string> KeyAsync(int index, IJSRuntime?jsRuntime) { return(jsRuntime.InvokeAsync <string>($"{_fullTypeName}.Key", index)); }
public async Task <T> GetItemAsync <T>(string key, IJSRuntime?jsRuntime) { var json = await GetItemAsync(key, jsRuntime); return(string.IsNullOrWhiteSpace(json) ? default : JsonSerializer.Deserialize <T>(json, _jsonSerializerOptions)); }
/// <summary> /// 显示或者隐藏 网站 Blazor 挂件图标 /// </summary> /// <param name="jSRuntime"></param> /// <param name="show"></param> public static void ToggleBlazor(this IJSRuntime?jSRuntime, bool show) => jSRuntime?.InvokeVoidAsync("$.toggleBlazor", show);
/// <summary> /// 显示或者隐藏 网站 Blazor 挂件图标 /// </summary> /// <param name="jSRuntime"></param> /// <param name="showSidebar"></param> /// <param name="showCardTitle"></param> /// <param name="fixedTableHeader"></param> public static void SetWebSettings(this IJSRuntime?jSRuntime, bool showSidebar, bool showCardTitle, bool fixedTableHeader) => jSRuntime?.InvokeVoidAsync("$.setWebSettings", showSidebar, showCardTitle, fixedTableHeader);
/// <summary> /// 导航条后移一个 Tab /// </summary> /// <param name="jSRuntime"></param> /// <returns></returns> public static async ValueTask <string> MoveNextTabAsync(this IJSRuntime?jSRuntime) => jSRuntime == null ? "" : await jSRuntime.InvokeAsync <string>("$.moveNextTab");
public ValueTask <object> SetItemAsync <T>(string key, T data, IJSRuntime?jsRuntime) { return(SetItemAsync(key, JsonSerializer.Serialize <T>(data, _jsonSerializerOptions), jsRuntime)); }
/// <summary> /// 启用动画 /// </summary> /// <param name="jSRuntime"></param> public static void InitDocument(this IJSRuntime?jSRuntime) => jSRuntime.InvokeVoidAsync("$.initDocument");
/// <summary> /// 移除指定 ID 的导航条 /// </summary> /// <param name="jSRuntime"></param> /// <param name="tabId"></param> /// <returns></returns> public static async ValueTask <string> RemoveTabAsync(this IJSRuntime?jSRuntime, string?tabId) => string.IsNullOrEmpty(tabId) || jSRuntime == null ? "" : await jSRuntime.InvokeAsync <string>("$.removeTab", tabId);
internal void SetJSRuntime(IJSRuntime jSRuntime) { this.jSRuntime = jSRuntime; this.jSInProcessRuntime = (IJSInProcessRuntime)jSRuntime; }
/// <summary> /// 修复 Modal 组件 /// </summary> /// <param name="jSRuntime"></param> public static void InitModal(this IJSRuntime?jSRuntime) => jSRuntime.InvokeVoidAsync("$.initModal");
/// <summary> /// 修复 Modal 组件 /// </summary> /// <param name="jSRuntime"></param> /// <param name="id"></param> public static void InitModal(this IJSRuntime?jSRuntime, string id) => jSRuntime.InvokeVoidAsync("$.initModal", id);
/// <summary> /// 弹出 Modal 组件 /// </summary> /// <param name="jSRuntime"></param> /// <param name="modalId"></param> public static void ToggleModal(this IJSRuntime?jSRuntime, string modalId) => jSRuntime.InvokeVoidAsync("$.toggleModal", modalId);
/// <summary> /// 弹出 Toast 组件 /// </summary> /// <param name="jSRuntime"></param> /// <param name="id"></param> public static void ShowToast(this IJSRuntime?jSRuntime, string id) => jSRuntime.InvokeVoidAsync("$.showToast", id);
/// <summary> /// 弹出 Tooltip 组件 /// </summary> /// <param name="jSRuntime"></param> /// <param name="id"></param> /// <param name="method"></param> public static void Tooltip(this IJSRuntime?jSRuntime, string id, string method) => jSRuntime.InvokeVoidAsync("$.tooltip", $"#{id}", method);
public LocalStoragePersistance(IJSRuntime?runtime) { Runtime = runtime; }