mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-02-20 15:58:11 +01:00
* Use latest ProtoBufJsonConverter to support WellKnownTypes * Fix * 02 * WireMockServer_WithBodyAsProtoBuf_WithWellKnownTypes * . * extra test * 0.4.0-preview-06 * 7 * <PackageReference Include="ProtoBufJsonConverter" Version="0.4.0-preview-08" /> * Update README.md * <PackageReference Include="ProtoBufJsonConverter" Version="0.4.0-preview-09" /> * <PackageReference Include="ProtoBufJsonConverter" Version="0.4.0" /> * Update README.md
59 lines
1.4 KiB
C#
59 lines
1.4 KiB
C#
// Copyright © WireMock.Net
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace WireMock.Models;
|
|
|
|
/// <summary>
|
|
/// A structure defining an (optional) Id and a Text.
|
|
/// </summary>
|
|
public readonly struct IdOrTexts
|
|
{
|
|
/// <summary>
|
|
/// The Id [optional].
|
|
/// </summary>
|
|
public string? Id { get; }
|
|
|
|
/// <summary>
|
|
/// The Text.
|
|
/// </summary>
|
|
public IReadOnlyList<string> Texts { get; }
|
|
|
|
/// <summary>
|
|
/// Create a IdOrText
|
|
/// </summary>
|
|
/// <param name="id">The Id [optional]</param>
|
|
/// <param name="text">The Text.</param>
|
|
public IdOrTexts(string? id, string text) : this(id, [text])
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Create a IdOrText
|
|
/// </summary>
|
|
/// <param name="id">The Id [optional]</param>
|
|
/// <param name="texts">The Texts.</param>
|
|
public IdOrTexts(string? id, IReadOnlyList<string> texts)
|
|
{
|
|
Id = id;
|
|
Texts = texts;
|
|
}
|
|
|
|
/// <summary>
|
|
/// When Id is defined, return process the Id, else process the Texts.
|
|
/// </summary>
|
|
/// <param name="id">Callback to process the id.</param>
|
|
/// <param name="texts">Callback to process the texts.</param>
|
|
public void Value(Action<string> id, Action<IReadOnlyList<string>> texts)
|
|
{
|
|
if (Id != null)
|
|
{
|
|
id(Id);
|
|
}
|
|
else
|
|
{
|
|
texts(Texts);
|
|
}
|
|
}
|
|
} |