/// <summary> /// Locks the orientation of the containing document to its default orientation /// </summary> /// <returns></returns> public async Task Lock(ScreenOrientationTypeEnum newOrientation) { await jsRuntime.InvokeInstanceMethodAsync(windowRef, "screen.orientation.lock", newOrientation switch { ScreenOrientationTypeEnum.Any => "any", ScreenOrientationTypeEnum.Natural => "natural", ScreenOrientationTypeEnum.Landscape => "landscape", ScreenOrientationTypeEnum.Portrait => "portrait", ScreenOrientationTypeEnum.PortraitPrimary => "portrait-primary", ScreenOrientationTypeEnum.PortraitSecondary => "portrait-secondary", ScreenOrientationTypeEnum.LandscapePrimary => "landscape-primary", ScreenOrientationTypeEnum.LandscapeSecondary => "landscape-secondary", _ => throw new NotImplementedException(), });
/// <summary> /// Returns a DOMHighResTimeStamp, which is a floating-point value providing an estimate of the number of milliseconds remaining in the current idle period. If the idle period is over, the value is 0. Your callback can call this repeatedly to see if there's enough time left to do more work before returning. /// </summary> /// <returns></returns> public async Task <TimeSpan> TimeRemaining() { return(TimeSpan.FromMilliseconds(await jsRuntime.InvokeInstanceMethodAsync <double>(jsRuntimeObject, "timeRemaining"))); }
/// <summary> /// removes the named mark from the browser's performance entry buffer. If the method is called with no arguments, all performance entries with an entry type of "mark" will be removed from the performance entry buffer. /// </summary> /// <param name="name"></param> /// <returns></returns> public async Task ClearMarks(string name = null) { await jsRuntime.InvokeInstanceMethodAsync(windowRef, "performance.clearMarks", name); }
/// <summary> /// Returns true if a call to Share() would succeed. /// Returns false if it would fail or sharing is not supported /// </summary> /// <returns></returns> public async Task <bool> CanShare(ShareData shareData) { return(await jsRuntime.HasProperty(jsRuntimeObjectRef, "navigator.canShare") && await jsRuntime.InvokeInstanceMethodAsync <bool>(jsRuntimeObjectRef, "navigator.canShare", shareData)); }
/// <summary> /// Will print an error with the given objectsin the output if the assertion is not verified /// </summary> /// <param name="assertion">true or false</param> /// <param name="printedObjects">object to print in the console</param> /// <returns></returns> public async Task Assert(bool assertion, params object[] printedObjects) { if (IsEnabled) { await jsRuntime.InvokeInstanceMethodAsync(windowObject, "browserInterop.callInstanceMethod", windowObject, "console.assert", assertion, printedObjects); } }
/// <summary> /// causes the browser to move back one page in the session history. It has the same effect as calling history.go(-1). If there is no previous page, this method call does nothing. /// </summary> /// <returns></returns> public async Task Back() { await jsRuntime.InvokeInstanceMethodAsync(jsRuntimeObjectRef, "history.back"); }
/// <summary> /// returns the name of the nth key in a given Storage object. The order of keys is user-agent defined, so you should not rely on it. /// </summary> /// <param name="index"></param> /// <returns></returns> public async Task <string> Key(int index) { return(await jsRuntime.InvokeInstanceMethodAsync <string>(jsRuntimeObjectRef, memberName + ".key", index)); }
/// <summary> /// Allows a developer to show the install prompt at a time of their own choosing. /// </summary> /// <returns></returns> public async Task Prompt() { await jSRuntime.InvokeInstanceMethodAsync(jsObjectRef, "prompt"); }