mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-02-17 15:57:41 +01:00
* Update aspire to 13.1 (examples + code) Allows usage of aspire CLI which is very useful for dev in codespaces (for my next PR). * Add OTEL support * Initial PR feedback * PR feedback * PR feedback * PR feedback * Cleanup. * Cleanup * Fix * Fix * Rename stuff around to be more accurate * PR feedback * Update WireMock.Net.OpenTelemetry.csproj Update <Authors> * PR feedback parser * PR feedback package versions * Status code feedback. * Update preprocessor directives to to Activity Tracing instead of OpenTelemetry. Is more descriptive. * Add tests * Improve tests --------- Co-authored-by: Stef Heyenrath <Stef.Heyenrath@gmail.com>
32 lines
729 B
C#
32 lines
729 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;
|
|
}
|
|
}
|