BlazorPlus.BlazorSession
Construct
You don't need to construct this object directly. As it have been declared as a scoped object in Startup.ConfigureServices, it will be created when any component inject it.
Get Instance
1 - use @inject BlazorSession bses in razor file
2 - use [Inject] BlazorSession bses{get;set;} in C# code , component class
3 - use BlazorSession.Current in case which not able to inject objects , require rendering context , not available in other threads
Static members
static public BlazorSession FindCurrent() - find BlazorSession in current thread , if not found, return null
static public BlazorSession Current{get;} - get BlazorSession in current thread , if not found, throw exception
static public BlazorSession FindSession(int id) - find a session by id
static public List<BlazorSession> GetSessions() - get all sessions in current app process
static public int InstanceCount{get;} - get live session count
static public int InstanceCreatedCount{get;} - get total session count after the app started
static public int InstanceRecycledCount{get;} - get total session count recycled by GC
static public int InstanceDisposedCount{get;} - get total session count disposed by Blazor
static public BlazorExceptionReportMode StaticExceptionReportMode { get; set; } - whether send error message to browser
Instance members
public int SessionId { get; private set; } - get the uniqueid of the session, 1,2,3,4... reset when process restart
public DateTime StartTime { get; } - get when the session created
public bool IsDisposed { get; private set; } - get whether the session is disposed by Blazor
public event EventHandler Disposed / Disposing; - event for knowing session end
public object this[object key] - use BlazorSession as a dictionary , store shared data between components
public Dictionary<object, object> GetItemMap(bool createIfNotExists) - get the inner dictionary of this[object key]
public Microsoft.JSInterop.IJSRuntime JSRuntime { get; } - get the IJSRuntime
public NavigationManager NavigationManager { get; private set; } - get the NavigationManager
public SynchronizationContext SynchronizationContext { get; } - get the SynchronizationContext for rendering thread
public ... PostToRenderThread...(...) - Invoke code in the rendering method
public ... InvokeInRenderThread...(...) - Invoke code in the rendering method
public BlazorContainer SharedContainer { get; set; } - get the <BlazorContainer IsShared='true'> in App.razor
public BlazorBrowser Browser{get;} - get the BlazorBrowser object
public void SetTimeout(int ms, Action handler) - run code after timeout , the code will not be executed if session disposed
public string WebRootPath{get;set;} - get or set the WebRootPath , default value is Path.Combine(Environment.CurrentDirectory, "wwwroot");
public void InstallScript(string absolutePath) - send a script file in wwwroot to browser, cache it in browser , and use the browser cache data.
public void AddWaitingMask() - call JavaScript AddWaitingMask() to show a waiting mask
public void SubWaitingMask() - call JavaScript AddWaitingMask() to hide the waiting mask
public void InvokeFunction(string funcexp, params object[] args) - call JavaScript function
public void InvokeFunction(string funcexp, params object[] args) - call JavaScript function
public void EvalCode(string code, params object[] args) - run JavaScript code , the args will act as JavaScript arguments
public void EvalCodeCache(string code, params object[] args) - run JavaScript code , the code will compile into cached function directly , only fit for fixed code be called many times
public async Task<object> EvalCodeAsync(string code, params object[] args) - run JavaScript , and get the result from the 'return' statement , don't support async/promise
public async Task<T> EvalCodeAsync<T>(string code, params object[] args) - run JavaScript , and get the result from the 'return' statement , don't support async/promise
public void FlushToClient() - send all script command immediatley , don't wait for next batch operation
public void HistoryBack() - equals EvalCode("history.back()");
public void ConsoleLog(params object[] items) - equals InvokeFunction("console.log", items);
public void ConsoleInfo(params object[] items) - equals InvokeFunction("console.info", items);
public void ConsoleWarn(params object[] items) - equals InvokeFunction("console.warn", items);
public void ConsoleError(params object[] items) - equals InvokeFunction("console.error", items);
public void Focus(ElementReference element) - send JavaScript to focus the element
public void Toast(string message, int? timeout = null, string key = null) - call JavaScript Toast to show a short message
public void ToastClear() - call JavaScript ToastClear to clear all messages
public void ShowDialog...(...) - Show BlazorDialog
Alert/AlertAsync - Show customizable alert box
Confirm/ConfirmAsync/ConfirmYes - Show customizable confirm box
Prompt/PromptAsync - Show customizable prompt box
Override members
public virtual Type TypeGetUIDialogAlert(UIDialogOption dialogOption) - get customizable implementation of the alert box
public virtual Type TypeGetUIDialogConfirm(UIDialogOption dialogOption) - get customizable implementation of the confirm box
public virtual Type TypeGetUIDialogPrompt(UIDialogOption dialogOption) - get customizable implementation of the parmpt box
The BlazorPlus.dll is ready for using.
But the contents of this website are being prepaired actively.
- Nuget
- BlazorPlusDemo - functional demo , Live Preview
- BlazorLinuxAdmin - 7 pages, Linux web control panel by ASP.NET Core Blazor server-side
- BlazorCefApp - 12 pages, Build windows desktop GUI app via CEF / WinForms / Blazor server-site
- Mobile - Boilerplate , comming soon.
Post issues if you have any questions https://github.com/BlazorPlus/BlazorPlus/issues