forked from Blazored/SessionStorage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathISyncSessionStorageService.cs
More file actions
82 lines (69 loc) · 3.38 KB
/
Copy pathISyncSessionStorageService.cs
File metadata and controls
82 lines (69 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System;
using System.Collections.Generic;
namespace Blazored.SessionStorage;
public interface ISyncSessionStorageService
{
/// <summary>
/// Clears all data from session storage.
/// </summary>
void Clear();
/// <summary>
/// Retrieve the specified data from session storage as a <typeparamref name="T"/>.
/// </summary>
/// <param name="key">A <see cref="string"/> value specifying the name of the session storage slot to use</param>
/// <returns>The data from the specified <paramref name="key"/> as a <typeparamref name="T"/></returns>
T GetItem<T>(string key);
/// <summary>
/// Retrieve the specified data from session storage as a <see cref="string"/>.
/// </summary>
/// <param name="key">A <see cref="string"/> value specifying the name of the storage slot to use</param>
/// <returns>The data associated with the specified <paramref name="key"/> as a <see cref="string"/></returns>
string GetItemAsString(string key);
/// <summary>
/// Return the name of the key at the specified <paramref name="index"/>.
/// </summary>
/// <param name="index"></param>
/// <returns>The name of the key at the specified <paramref name="index"/></returns>
string Key(int index);
/// <summary>
/// Get the keys of all items stored in session storage.
/// </summary>
/// <returns>The keys of all items stored in session storage</returns>
IEnumerable<string> Keys();
/// <summary>
/// Checks if the <paramref name="key"/> exists in session storage, but does not check its value.
/// </summary>
/// <param name="key">A <see cref="string"/> value specifying the name of the storage slot to use</param>
/// <returns>Boolean indicating if the specified <paramref name="key"/> exists</returns>
bool ContainKey(string key);
/// <summary>
/// The number of items stored in session storage.
/// </summary>
/// <returns>The number of items stored in session storage</returns>
int Length();
/// <summary>
/// Remove the data with the specified <paramref name="key"/>.
/// </summary>
/// <param name="key">A <see cref="string"/> value specifying the name of the storage slot to use</param>
void RemoveItem(string key);
/// <summary>
/// Removes a collection of <paramref name="keys"/>.
/// </summary>
/// <param name="keys">A IEnumerable collection of strings specifying the name of the storage slot to remove</param>
void RemoveItems(IEnumerable<string> keys);
/// <summary>
/// Sets or updates the <paramref name="data"/> in session storage with the specified <paramref name="key"/>.
/// </summary>
/// <param name="key">A <see cref="string"/> value specifying the name of the storage slot to use</param>
/// <param name="data">The data to be saved</param>
void SetItem<T>(string key, T data);
/// <summary>
/// Sets or updates the <paramref name="data"/> in session storage with the specified <paramref name="key"/>. Does not serialize the value before storing.
/// </summary>
/// <param name="key">A <see cref="string"/> value specifying the name of the storage slot to use</param>
/// <param name="data">The string to be saved</param>
/// <returns></returns>
void SetItemAsString(string key, string data);
event EventHandler<ChangingEventArgs> Changing;
event EventHandler<ChangedEventArgs> Changed;
}