Skip to content

Commit a17874b

Browse files
committed
fix(Sdk): Added Keys and Values properties to the Map class
fix(Sdk): Added a new `GetEntry` method, used to get the MapEntry with the specified key Signed-off-by: Charles d'Avernas <[email protected]>
1 parent bdc4330 commit a17874b

File tree

5 files changed

+38
-3
lines changed

5 files changed

+38
-3
lines changed

src/ServerlessWorkflow.Sdk.Builders/ServerlessWorkflow.Sdk.Builders.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<VersionPrefix>1.0.0</VersionPrefix>
8-
<VersionSuffix>alpha2.1</VersionSuffix>
8+
<VersionSuffix>alpha2.2</VersionSuffix>
99
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1010
<FileVersion>$(VersionPrefix)</FileVersion>
1111
<NeutralLanguage>en</NeutralLanguage>

src/ServerlessWorkflow.Sdk.IO/ServerlessWorkflow.Sdk.IO.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<VersionPrefix>1.0.0</VersionPrefix>
8-
<VersionSuffix>alpha2.1</VersionSuffix>
8+
<VersionSuffix>alpha2.2</VersionSuffix>
99
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1010
<FileVersion>$(VersionPrefix)</FileVersion>
1111
<NeutralLanguage>en</NeutralLanguage>

src/ServerlessWorkflow.Sdk/OrderedMap.cs renamed to src/ServerlessWorkflow.Sdk/Map.cs

+22
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ public record Map<TKey, TValue>
2727

2828
readonly Dictionary<TKey, TValue> _entries = [];
2929

30+
/// <summary>
31+
/// Gets an <see cref="IReadOnlyList{T}"/> that contains all the map's keys
32+
/// </summary>
33+
public IReadOnlyList<TKey> Keys => [.. this._entries.Keys];
34+
35+
/// <summary>
36+
/// Gets an <see cref="IReadOnlyList{T}"/> that contains all the map's values
37+
/// </summary>
38+
public IReadOnlyList<TValue> Values => [.. this._entries.Values];
39+
3040
/// <inheritdoc/>
3141
public int Count => this._entries.Count;
3242

@@ -51,6 +61,18 @@ public TValue this[TKey key]
5161
}
5262
}
5363

64+
/// <summary>
65+
/// Gets the <see cref="MapEntry{TKey, TValue}"/> with the specified key
66+
/// </summary>
67+
/// <param name="key">The key of the <see cref="MapEntry{TKey, TValue}"/> to get</param>
68+
/// <returns>The <see cref="MapEntry{TKey, TValue}"/> with the specified key</returns>
69+
public virtual MapEntry<TKey, TValue>? GetEntry(TKey key)
70+
{
71+
var kvp = this._entries.FirstOrDefault(e => e.Key.Equals(key));
72+
if (kvp.Key.Equals(default(TKey))) return null;
73+
else return new(kvp.Key, kvp.Value);
74+
}
75+
5476
/// <inheritdoc/>
5577
public virtual void Add(MapEntry<TKey, TValue> item) => this._entries[item.Key] = item.Value;
5678

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
https://go.microsoft.com/fwlink/?LinkID=208121.
4+
-->
5+
<Project>
6+
<PropertyGroup>
7+
<Configuration>Release</Configuration>
8+
<Platform>Any CPU</Platform>
9+
<PublishDir>bin\Release\net8.0\publish\</PublishDir>
10+
<PublishProtocol>FileSystem</PublishProtocol>
11+
<_TargetId>Folder</_TargetId>
12+
</PropertyGroup>
13+
</Project>

src/ServerlessWorkflow.Sdk/ServerlessWorkflow.Sdk.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<VersionPrefix>1.0.0</VersionPrefix>
8-
<VersionSuffix>alpha2.1</VersionSuffix>
8+
<VersionSuffix>alpha2.2</VersionSuffix>
99
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1010
<FileVersion>$(VersionPrefix)</FileVersion>
1111
<NeutralLanguage>en</NeutralLanguage>

0 commit comments

Comments
 (0)