mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-31 22:23:05 +02:00
* Add TIOBE + include SonarAnalyzer.CSharp * . * cp * Copyright © WireMock.Net * more fixes * fix * xpath * if (Matchers == null || !Matchers.Any()) * if (Matchers != null) * ? * . * .
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;
|
|
}
|
|
} |