mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-18 08:07:09 +01:00
* Add new package WireMock.Net.Extensions.Routing * Update documentation for WireMock.Net.Extensions.Routing * Cleanup imports * Add header to all source files inside WireMock.Net.Extensions.Routing * Add header to all source files inside WireMock.Net.Extensions.Routing.Tests * Revert unintended changes * Remove redundant build configurations * Remove incorrect links from documentation * Update nuget package references * Revert unintended changes * Migrate to AwesomeAssertions * Remove redundant project reference * Adjust formatting * Migrate to primary constructor * Refactoring: rename delegate parameter * Abstract over JSON converter * Replace WireMock with WireMock.Net in comments * Move local functions to the bottom of the methods
20 lines
542 B
C#
20 lines
542 B
C#
// Copyright © WireMock.Net
|
|
|
|
using System.Collections.Immutable;
|
|
|
|
namespace WireMock.Net.Extensions.Routing.Extensions;
|
|
|
|
internal static class DictionaryExtensions
|
|
{
|
|
public static IDictionary<TKey, TValue> AddIf<TKey, TValue>(
|
|
this IDictionary<TKey, TValue> source,
|
|
bool condition,
|
|
TKey key,
|
|
TValue value,
|
|
IEqualityComparer<TKey>? keyComparer = null)
|
|
where TKey : notnull =>
|
|
condition
|
|
? source.ToImmutableDictionary(keyComparer).Add(key, value)
|
|
: source;
|
|
}
|