File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed
src/Blazor.Extensions.Storage
test/Blazor.Extensions.Storage.Test/Pages Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ public void SetItem<TItem>(string key, TItem item)
35
35
36
36
public class LocalStorage
37
37
{
38
+ public int Length => RegisteredFunction . Invoke < int > ( MethodNames . LENGTH_METHOD , StorageTypeNames . LOCAL_STORAGE ) ;
38
39
public void Clear ( ) => RegisteredFunction . InvokeUnmarshalled < object > ( MethodNames . CLEAR_METHOD , StorageTypeNames . LOCAL_STORAGE ) ;
39
40
40
41
public TItem GetItem < TItem > ( string key )
Original file line number Diff line number Diff line change 15
15
var key = " forecasts" ;
16
16
SessionStorage .SetItem <WeatherForecast []>(key , forecasts );
17
17
LocalStorage .SetItem <WeatherForecast []>(key , forecasts );
18
+
18
19
var fromSession = SessionStorage .GetItem <WeatherForecast []>(key );
19
20
var fromLocal = LocalStorage .GetItem <WeatherForecast []>(key );
20
21
21
22
logger .LogInformation (" From session storage:" );
22
23
logger .LogInformation (fromSession );
23
24
logger .LogInformation (" From local storage:" );
24
25
logger .LogInformation (fromLocal );
26
+
25
27
logger .LogInformation ($" Total in session: {SessionStorage .Length }" );
26
- logger .LogInformation ($" Total in local: {SessionStorage .Length }" );
28
+ logger .LogInformation ($" Total in local: {LocalStorage .Length }" );
29
+
27
30
logger .LogInformation (" Removing from session storage..." );
28
31
SessionStorage .RemoveItem (key );
29
32
logger .LogInformation (" Removing from local storage..." );
30
33
LocalStorage .RemoveItem (key );
34
+
31
35
logger .LogInformation ($" Total in session: {SessionStorage .Length }" );
32
36
logger .LogInformation ($" Total in local: {SessionStorage .Length }" );
33
37
}
You can’t perform that action at this time.
0 commit comments