finish implementing path parameters
This commit is contained in:
1 parent
a24543063b
commit
fecd40cd57
5 files changed
+236
-27
No files matched your search
@@ -0,0 +1,22 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace SimpleHttpServer.Types;
|
||||
internal class MultiKeyDictionary<K1, K2, V> where K1 : notnull where K2 : notnull {
|
||||
internal readonly Dictionary<K1, Dictionary<K2, V>> backingDict = new();
|
||||
public MultiKeyDictionary() { }
|
||||
|
||||
public void Add(K1 k1, K2 k2, V value) {
|
||||
if (!backingDict.TryGetValue(k1, out var d2))
|
||||
d2 = new();
|
||||
d2.Add(k2, value);
|
||||
backingDict[k1] = d2;
|
||||
}
|
||||
|
||||
public bool TryGetValue(K1 k1, K2 k2, [MaybeNullWhen(false)] out V value) {
|
||||
if (backingDict.TryGetValue(k1, out var d2) && d2.TryGetValue(k2, out value))
|
||||
return true;
|
||||
|
||||
value = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user