Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working when you refrence in Razor Class Library #72

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions src/Blazored.SessionStorage/BrowserStorageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public async ValueTask ClearAsync(CancellationToken cancellationToken = default)
{
try
{
await _jSRuntime.InvokeVoidAsync("sessionStorage.clear", cancellationToken);
await _jSRuntime.InvokeVoidAsync("window.sessionStorage.clear", cancellationToken);
}
catch (Exception exception)
{
Expand All @@ -41,7 +41,7 @@ public async ValueTask<string> GetItemAsync(string key, CancellationToken cancel
{
try
{
return await _jSRuntime.InvokeAsync<string>("sessionStorage.getItem", cancellationToken, key);
return await _jSRuntime.InvokeAsync<string>("window.sessionStorage.getItem", cancellationToken, key);
}
catch (Exception exception)
{
Expand All @@ -58,7 +58,7 @@ public async ValueTask<string> KeyAsync(int index, CancellationToken cancellatio
{
try
{
return await _jSRuntime.InvokeAsync<string>("sessionStorage.key", cancellationToken, index);
return await _jSRuntime.InvokeAsync<string>("window.sessionStorage.key", cancellationToken, index);
}
catch (Exception exception)
{
Expand Down Expand Up @@ -92,7 +92,7 @@ public async ValueTask<bool> ContainKeyAsync(string key, CancellationToken cance
{
try
{
return await _jSRuntime.InvokeAsync<bool>("sessionStorage.hasOwnProperty", cancellationToken, key);
return await _jSRuntime.InvokeAsync<bool>("window.sessionStorage.hasOwnProperty", cancellationToken, key);
}
catch (Exception exception)
{
Expand All @@ -109,7 +109,7 @@ public async ValueTask<int> LengthAsync(CancellationToken cancellationToken = de
{
try
{
return await _jSRuntime.InvokeAsync<int>("eval", cancellationToken, "sessionStorage.length");
return await _jSRuntime.InvokeAsync<int>("eval", cancellationToken, "window.sessionStorage.length");
}
catch (Exception exception)
{
Expand All @@ -126,7 +126,7 @@ public async ValueTask RemoveItemAsync(string key, CancellationToken cancellatio
{
try
{
await _jSRuntime.InvokeVoidAsync("sessionStorage.removeItem", cancellationToken, key);
await _jSRuntime.InvokeVoidAsync("window.sessionStorage.removeItem", cancellationToken, key);
}
catch (Exception exception)
{
Expand All @@ -145,7 +145,7 @@ public async ValueTask RemoveItemsAsync(IEnumerable<string> keys, CancellationTo
{
foreach (var key in keys)
{
await _jSRuntime.InvokeVoidAsync("sessionStorage.removeItem", cancellationToken, key);
await _jSRuntime.InvokeVoidAsync("window.sessionStorage.removeItem", cancellationToken, key);
}
}
catch (Exception exception)
Expand All @@ -163,7 +163,7 @@ public async ValueTask SetItemAsync(string key, string data, CancellationToken c
{
try
{
await _jSRuntime.InvokeVoidAsync("sessionStorage.setItem", cancellationToken, key, data);
await _jSRuntime.InvokeVoidAsync("window.sessionStorage.setItem", cancellationToken, key, data);
}
catch (Exception exception)
{
Expand All @@ -181,7 +181,7 @@ public void Clear()
CheckForInProcessRuntime();
try
{
_jSInProcessRuntime.InvokeVoid("sessionStorage.clear");
_jSInProcessRuntime.InvokeVoid("window.sessionStorage.clear");
}
catch (Exception exception)
{
Expand All @@ -199,7 +199,7 @@ public string GetItem(string key)
CheckForInProcessRuntime();
try
{
return _jSInProcessRuntime.Invoke<string>("sessionStorage.getItem", key);
return _jSInProcessRuntime.Invoke<string>("window.sessionStorage.getItem", key);
}
catch (Exception exception)
{
Expand All @@ -217,7 +217,7 @@ public string Key(int index)
CheckForInProcessRuntime();
try
{
return _jSInProcessRuntime.Invoke<string>("sessionStorage.key", index);
return _jSInProcessRuntime.Invoke<string>("window.sessionStorage.key", index);
}
catch (Exception exception)
{
Expand Down Expand Up @@ -253,7 +253,7 @@ public bool ContainKey(string key)
CheckForInProcessRuntime();
try
{
return _jSInProcessRuntime.Invoke<bool>("sessionStorage.hasOwnProperty", key);
return _jSInProcessRuntime.Invoke<bool>("window.sessionStorage.hasOwnProperty", key);
}
catch (Exception exception)
{
Expand All @@ -271,7 +271,7 @@ public int Length()
CheckForInProcessRuntime();
try
{
return _jSInProcessRuntime.Invoke<int>("eval", "sessionStorage.length");
return _jSInProcessRuntime.Invoke<int>("eval", "window.sessionStorage.length");
}
catch (Exception exception)
{
Expand All @@ -289,7 +289,7 @@ public void RemoveItem(string key)
CheckForInProcessRuntime();
try
{
_jSInProcessRuntime.InvokeVoid("sessionStorage.removeItem", key);
_jSInProcessRuntime.InvokeVoid("window.sessionStorage.removeItem", key);
}
catch (Exception exception)
{
Expand All @@ -309,7 +309,7 @@ public void RemoveItems(IEnumerable<string> keys)
{
foreach (var key in keys)
{
_jSInProcessRuntime.InvokeVoid("sessionStorage.removeItem", key);
_jSInProcessRuntime.InvokeVoid("window.sessionStorage.removeItem", key);
}
}
catch (Exception exception)
Expand All @@ -328,7 +328,7 @@ public void SetItem(string key, string data)
CheckForInProcessRuntime();
try
{
_jSInProcessRuntime.InvokeVoid("sessionStorage.setItem", key, data);
_jSInProcessRuntime.InvokeVoid("window.sessionStorage.setItem", key, data);
}
catch (Exception exception)
{
Expand Down