mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-16 07:06:54 +01:00
* Create WireMock.Net.MimePart project * . * REFACTOR * ILRepack * -- * ... * x * x * . * fix * public class MimePartMatcher * shared * min * . * <!--<DelaySign>true</DelaySign>--> * Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
31 lines
728 B
C#
31 lines
728 B
C#
// Copyright © WireMock.Net
|
|
|
|
using System.Collections;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using Stef.Validation;
|
|
|
|
namespace WireMock.Extensions;
|
|
|
|
internal static class DictionaryExtensions
|
|
{
|
|
public static bool TryGetStringValue(this IDictionary dictionary, string key, [NotNullWhen(true)] out string? value)
|
|
{
|
|
Guard.NotNull(dictionary);
|
|
|
|
if (dictionary[key] is string valueIsString)
|
|
{
|
|
value = valueIsString;
|
|
return true;
|
|
}
|
|
|
|
var valueToString = dictionary[key]?.ToString();
|
|
if (valueToString != null)
|
|
{
|
|
value = valueToString;
|
|
return true;
|
|
}
|
|
|
|
value = default;
|
|
return false;
|
|
}
|
|
} |