|
| 1 | +using Blazor.Extensions.Storage.Interfaces; |
1 | 2 | using Microsoft.AspNetCore.Blazor;
|
2 | 3 | using Microsoft.AspNetCore.Blazor.Browser.Interop;
|
3 | 4 | using System;
|
4 | 5 |
|
5 |
| -namespace Blazor.Extensions |
| 6 | +namespace Blazor.Extensions.Storage |
6 | 7 | {
|
7 |
| - public class SessionStorage |
| 8 | + public class SessionStorage : IStorage |
8 | 9 | {
|
9 | 10 | public int Length => RegisteredFunction.Invoke<int>(MethodNames.LENGTH_METHOD, StorageTypeNames.SESSION_STORAGE);
|
10 | 11 | public void Clear() => RegisteredFunction.InvokeUnmarshalled<object>(MethodNames.CLEAR_METHOD, StorageTypeNames.SESSION_STORAGE);
|
@@ -32,33 +33,4 @@ public void SetItem<TItem>(string key, TItem item)
|
32 | 33 | RegisteredFunction.Invoke<object>(MethodNames.SET_ITEM_METHOD, StorageTypeNames.SESSION_STORAGE, key, JsonUtil.Serialize(item));
|
33 | 34 | }
|
34 | 35 | }
|
35 |
| - |
36 |
| - public class LocalStorage |
37 |
| - { |
38 |
| - public int Length => RegisteredFunction.Invoke<int>(MethodNames.LENGTH_METHOD, StorageTypeNames.LOCAL_STORAGE); |
39 |
| - public void Clear() => RegisteredFunction.InvokeUnmarshalled<object>(MethodNames.CLEAR_METHOD, StorageTypeNames.LOCAL_STORAGE); |
40 |
| - |
41 |
| - public TItem GetItem<TItem>(string key) |
42 |
| - { |
43 |
| - if (string.IsNullOrWhiteSpace(key)) throw new ArgumentNullException(nameof(key)); |
44 |
| - |
45 |
| - return RegisteredFunction.Invoke<TItem>(MethodNames.GET_ITEM_METHOD, StorageTypeNames.LOCAL_STORAGE, key); |
46 |
| - } |
47 |
| - |
48 |
| - public string Key(int index) => RegisteredFunction.Invoke<string>(MethodNames.KEY_METHOD, StorageTypeNames.LOCAL_STORAGE, index); |
49 |
| - |
50 |
| - public void RemoveItem(string key) |
51 |
| - { |
52 |
| - if (string.IsNullOrWhiteSpace(key)) throw new ArgumentNullException(nameof(key)); |
53 |
| - |
54 |
| - RegisteredFunction.InvokeUnmarshalled<object>(MethodNames.REMOVE_ITEM_METHOD, StorageTypeNames.LOCAL_STORAGE, key); |
55 |
| - } |
56 |
| - |
57 |
| - public void SetItem<TItem>(string key, TItem item) |
58 |
| - { |
59 |
| - if (string.IsNullOrWhiteSpace(key)) throw new ArgumentNullException(nameof(key)); |
60 |
| - |
61 |
| - RegisteredFunction.Invoke<object>(MethodNames.SET_ITEM_METHOD, StorageTypeNames.LOCAL_STORAGE, key, JsonUtil.Serialize(item)); |
62 |
| - } |
63 |
| - } |
64 | 36 | }
|
0 commit comments