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);
     }
 }
Example #3
0
 public static ValueTask <bool> CreateOrJoinRoomAsync(
     this IJSRuntime?jsRuntime,
     string roomName,
     string token) =>
 jsRuntime?.InvokeAsync <bool>(
     "videoInterop.createOrJoinRoom",
     roomName, token) ?? new ValueTask <bool>(false);
Example #4
0
 /// <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);
     }
 }
Example #5
0
        /// <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})");
            }
        }
Example #6
0
        /// <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;
            }
        }
Example #8
0
 /// <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");
Example #12
0
 /// <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);
Example #13
0
 public ValueTask <object> SetItemAsync(string key, string?data, IJSRuntime?jsRuntime)
 {
     return(jsRuntime.InvokeAsync <object>($"{_fullTypeName}.SetItem", key, data));
 }
Example #14
0
 public void RemoveItem(string key, IJSRuntime?jsRuntime)
 {
     jsRuntime.InvokeAsync <object>($"{_fullTypeName}.RemoveItem", key, key);
 }
Example #15
0
 public ValueTask <object> RemoveItemAsync(string key, IJSRuntime?jsRuntime)
 {
     return(jsRuntime.InvokeAsync <object>($"{_fullTypeName}.RemoveItem", key));
 }
Example #16
0
 public ValueTask <string> KeyAsync(int index, IJSRuntime?jsRuntime)
 {
     return(jsRuntime.InvokeAsync <string>($"{_fullTypeName}.Key", index));
 }
Example #17
0
        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));
        }
Example #18
0
 /// <summary>
 /// 显示或者隐藏 网站 Blazor 挂件图标
 /// </summary>
 /// <param name="jSRuntime"></param>
 /// <param name="show"></param>
 public static void ToggleBlazor(this IJSRuntime?jSRuntime, bool show) => jSRuntime?.InvokeVoidAsync("$.toggleBlazor", show);
Example #19
0
 /// <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");
Example #21
0
 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);
Example #24
0
 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");
Example #26
0
 /// <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);
Example #28
0
 /// <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);
Example #30
0
 public LocalStoragePersistance(IJSRuntime?runtime)
 {
     Runtime = runtime;
 }