-
Notifications
You must be signed in to change notification settings - Fork 383
Expand file tree
/
Copy pathISettingsStorageHelper.cs
More file actions
42 lines (37 loc) · 1.54 KB
/
ISettingsStorageHelper.cs
File metadata and controls
42 lines (37 loc) · 1.54 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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace CommunityToolkit.Common.Helpers;
/// <summary>
/// Service interface used to store data using key value pairs.
/// </summary>
/// <typeparam name="TKey">The type of keys to use for accessing values.</typeparam>
public interface ISettingsStorageHelper<in TKey>
where TKey : notnull
{
/// <summary>
/// Retrieves a single item by its key.
/// </summary>
/// <typeparam name="TValue">Type of object retrieved.</typeparam>
/// <param name="key">Key of the object.</param>
/// <param name="value">The <see typeparamref="TValue"/> object for <see typeparamref="TKey"/> key.</param>
/// <returns>A boolean indicator of success.</returns>
bool TryRead<TValue>(TKey key, out TValue? value);
/// <summary>
/// Saves a single item by its key.
/// </summary>
/// <typeparam name="TValue">Type of object saved.</typeparam>
/// <param name="key">Key of the value saved.</param>
/// <param name="value">Object to save.</param>
void Save<TValue>(TKey key, TValue value);
/// <summary>
/// Deletes a single item by its key.
/// </summary>
/// <param name="key">Key of the object.</param>
/// <returns>A boolean indicator of success.</returns>
bool TryDelete(TKey key);
/// <summary>
/// Clear all keys and values from the settings store.
/// </summary>
void Clear();
}