public T Deserialize <T>(string json, T defValue) where T : notnull { try { if (String.IsNullOrEmpty(json)) { return(defValue); } var r = JsonSerializer.Deserialize <T>(json); return((r == null) ? defValue : r); } catch (Exception) { var typ = defValue.GetType().Name; DBG.Err($"Json Deserialize error: '{json}' is not a '{typ}'"); return(defValue); } }
static public async Task <JSInit> InitAsync(IJSRuntime jsr) { try { var module = await jsr.InvokeAsync <IJSObjectReference>( "import", "/_content/IcuBlazor/interop.js"); var jsinit = new JSInit(jsr, module); await jsinit.JSI.HealthCheck(); ENV.Browser = await jsinit.JSI.DetectBrowser(); return(jsinit); } catch (Exception e) { DBG.Err(e.Message); // may be actual script error throw; } }