Skip to content

Commit 7e92bb3

Browse files
committed
Add InMemoryConnection class implementing IReadOnlyConnection
1 parent 6435b5e commit 7e92bb3

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

src/InMemoryConnection.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
namespace WindowsAppCommunity.Sdk;
2+
3+
/// <summary>
4+
/// An in-memory implementation of <see cref="IReadOnlyConnection"/>.
5+
/// </summary>
6+
/// <remarks>
7+
/// This class is used to create a basic connection value to be added to a collection.
8+
/// </remarks>
9+
public class InMemoryConnection : IReadOnlyConnection
10+
{
11+
/// <summary>
12+
/// An Id for the connection.
13+
/// </summary>
14+
public required string Id { get; init; }
15+
16+
/// <summary>
17+
/// The value of the connection.
18+
/// </summary>
19+
public required string Value { get; init; }
20+
21+
/// <inheritdoc/>
22+
public Task<string> GetValueAsync(CancellationToken cancellationToken = default)
23+
{
24+
return Task.FromResult(Value);
25+
}
26+
27+
/// <inheritdoc/>
28+
public event EventHandler<string>? ValueUpdated;
29+
}

0 commit comments

Comments
 (0)