Refactor some code (IBodyDataExtensions)

This commit is contained in:
Stef Heyenrath
2024-09-20 13:52:45 +02:00
parent dd80fd7822
commit 2cbbef01ae
3 changed files with 30 additions and 24 deletions

View File

@@ -0,0 +1,25 @@
// Copyright © WireMock.Net
using WireMock.Types;
// ReSharper disable once CheckNamespace
namespace WireMock.Util;
// ReSharper disable once InconsistentNaming
public static class IBodyDataExtensions
{
public static BodyType GetBodyType(this IBodyData bodyData)
{
if (bodyData.DetectedBodyTypeFromContentType is not null and not BodyType.None)
{
return bodyData.DetectedBodyTypeFromContentType.Value;
}
if (bodyData.DetectedBodyType is not null and not BodyType.None)
{
return bodyData.DetectedBodyType.Value;
}
return BodyType.None;
}
}