using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Microsoft.JSInterop; namespace Blazored.SessionStorage; public interface ISessionStorageService { /// /// Clears all data from session storage. /// /// A representing the completion of the operation. ValueTask ClearAsync(CancellationToken cancellationToken = default); /// /// Retrieve the specified data from session storage and deseralise it to the specfied type. /// /// A value specifying the name of the session storage slot to use /// A cancellation token to signal the cancellation of the operation. Specifying this parameter will override any default cancellations such as due to timeouts () from being applied. /// A representing the completion of the operation. ValueTask GetItemAsync(string key, CancellationToken cancellationToken = default); /// /// Retrieve the specified data from session storage as a . /// /// A value specifying the name of the storage slot to use /// A cancellation token to signal the cancellation of the operation. Specifying this parameter will override any default cancellations such as due to timeouts () from being applied. /// A representing the completion of the operation. ValueTask GetItemAsStringAsync(string key, CancellationToken cancellationToken = default); /// /// Return the name of the key at the specified . /// /// /// A cancellation token to signal the cancellation of the operation. Specifying this parameter will override any default cancellations such as due to timeouts () from being applied. /// A representing the completion of the operation. ValueTask KeyAsync(int index, CancellationToken cancellationToken = default); /// /// Returns a collection of strings representing the names of the keys in the Session storage. /// /// A cancellation token to signal the cancellation of the operation. Specifying this parameter will override any default cancellations such as due to timeouts () from being applied. /// A representing the completion of the operation. ValueTask> KeysAsync(CancellationToken cancellationToken = default); /// /// Checks if the exists in session storage, but does not check its value. /// /// A value specifying the name of the storage slot to use /// A cancellation token to signal the cancellation of the operation. Specifying this parameter will override any default cancellations such as due to timeouts () from being applied. /// A representing the completion of the operation. ValueTask ContainKeyAsync(string key, CancellationToken cancellationToken = default); /// /// The number of items stored in session storage. /// /// A cancellation token to signal the cancellation of the operation. Specifying this parameter will override any default cancellations such as due to timeouts () from being applied. /// A representing the completion of the operation. ValueTask LengthAsync(CancellationToken cancellationToken = default); /// /// Remove the data with the specified . /// /// A value specifying the name of the storage slot to use /// A cancellation token to signal the cancellation of the operation. Specifying this parameter will override any default cancellations such as due to timeouts () from being applied. /// A representing the completion of the operation. ValueTask RemoveItemAsync(string key, CancellationToken cancellationToken = default); /// /// Removes a collection of . /// /// A IEnumerable collection of strings specifying the name of the storage slot to remove /// A cancellation token to signal the cancellation of the operation. Specifying this parameter will override any default cancellations such as due to timeouts () from being applied. /// A representing the completion of the operation. ValueTask RemoveItemsAsync(IEnumerable keys, CancellationToken cancellationToken = default); /// /// Sets or updates the in session storage with the specified . /// /// A value specifying the name of the storage slot to use /// The data to be saved /// A cancellation token to signal the cancellation of the operation. Specifying this parameter will override any default cancellations such as due to timeouts () from being applied. /// A representing the completion of the operation. ValueTask SetItemAsync(string key, T data, CancellationToken cancellationToken = default); /// /// Sets or updates the in session storage with the specified . Does not serialize the value before storing. /// /// A value specifying the name of the storage slot to use /// The string to be saved /// A cancellation token to signal the cancellation of the operation. Specifying this parameter will override any default cancellations such as due to timeouts () from being applied. /// A representing the completion of the operation. ValueTask SetItemAsStringAsync(string key, string data, CancellationToken cancellationToken = default); event EventHandler Changing; event EventHandler Changed; }