Skip to content

Commit

Permalink
fix(Sdk): Added Keys and Values properties to the Map class
Browse files Browse the repository at this point in the history
fix(Sdk): Added a new `GetEntry` method, used to get the MapEntry with the specified key

Signed-off-by: Charles d'Avernas <[email protected]>
  • Loading branch information
cdavernas committed Jun 25, 2024
1 parent bdc4330 commit a17874b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>alpha2.1</VersionSuffix>
<VersionSuffix>alpha2.2</VersionSuffix>
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
<FileVersion>$(VersionPrefix)</FileVersion>
<NeutralLanguage>en</NeutralLanguage>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>alpha2.1</VersionSuffix>
<VersionSuffix>alpha2.2</VersionSuffix>
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
<FileVersion>$(VersionPrefix)</FileVersion>
<NeutralLanguage>en</NeutralLanguage>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ public record Map<TKey, TValue>

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

/// <summary>
/// Gets an <see cref="IReadOnlyList{T}"/> that contains all the map's keys
/// </summary>
public IReadOnlyList<TKey> Keys => [.. this._entries.Keys];

/// <summary>
/// Gets an <see cref="IReadOnlyList{T}"/> that contains all the map's values
/// </summary>
public IReadOnlyList<TValue> Values => [.. this._entries.Values];

/// <inheritdoc/>
public int Count => this._entries.Count;

Expand All @@ -51,6 +61,18 @@ public TValue this[TKey key]
}
}

/// <summary>
/// Gets the <see cref="MapEntry{TKey, TValue}"/> with the specified key
/// </summary>
/// <param name="key">The key of the <see cref="MapEntry{TKey, TValue}"/> to get</param>
/// <returns>The <see cref="MapEntry{TKey, TValue}"/> with the specified key</returns>
public virtual MapEntry<TKey, TValue>? GetEntry(TKey key)
{
var kvp = this._entries.FirstOrDefault(e => e.Key.Equals(key));
if (kvp.Key.Equals(default(TKey))) return null;
else return new(kvp.Key, kvp.Value);
}

/// <inheritdoc/>
public virtual void Add(MapEntry<TKey, TValue> item) => this._entries[item.Key] = item.Value;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net8.0\publish\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/ServerlessWorkflow.Sdk/ServerlessWorkflow.Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>alpha2.1</VersionSuffix>
<VersionSuffix>alpha2.2</VersionSuffix>
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
<FileVersion>$(VersionPrefix)</FileVersion>
<NeutralLanguage>en</NeutralLanguage>
Expand Down

0 comments on commit a17874b

Please sign in to comment.