mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-01 15:13:33 +02:00
Make CSharpCodeMatcher public (#1337)
This commit is contained in:
@@ -18,7 +18,7 @@ namespace WireMock.Matchers;
|
|||||||
/// CSharpCode / CS-Script Matcher
|
/// CSharpCode / CS-Script Matcher
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <inheritdoc cref="ICSharpCodeMatcher"/>
|
/// <inheritdoc cref="ICSharpCodeMatcher"/>
|
||||||
internal class CSharpCodeMatcher : ICSharpCodeMatcher
|
public class CSharpCodeMatcher : ICSharpCodeMatcher
|
||||||
{
|
{
|
||||||
private const string TemplateForIsMatchWithString = "public class CodeHelper {{ public bool IsMatch(string it) {{ {0} }} }}";
|
private const string TemplateForIsMatchWithString = "public class CodeHelper {{ public bool IsMatch(string it) {{ {0} }} }}";
|
||||||
|
|
||||||
@@ -63,17 +63,24 @@ internal class CSharpCodeMatcher : ICSharpCodeMatcher
|
|||||||
Value = patterns;
|
Value = patterns;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MatchResult IsMatch(string? input)
|
/// <inheritdoc />
|
||||||
|
public MatchResult IsMatch(string? input) => IsMatchInternal(input);
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public MatchResult IsMatch(object? input) => IsMatchInternal(input);
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public string GetCSharpCodeArguments()
|
||||||
{
|
{
|
||||||
return IsMatchInternal(input);
|
return $"new {Name}" +
|
||||||
|
$"(" +
|
||||||
|
$"{MatchBehaviour.GetFullyQualifiedEnumValue()}, " +
|
||||||
|
$"{MatchOperator.GetFullyQualifiedEnumValue()}, " +
|
||||||
|
$"{MappingConverterUtils.ToCSharpCodeArguments(_patterns)}" +
|
||||||
|
$")";
|
||||||
}
|
}
|
||||||
|
|
||||||
public MatchResult IsMatch(object? input)
|
private MatchResult IsMatchInternal(object? input)
|
||||||
{
|
|
||||||
return IsMatchInternal(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MatchResult IsMatchInternal(object? input)
|
|
||||||
{
|
{
|
||||||
var score = MatchScores.Mismatch;
|
var score = MatchScores.Mismatch;
|
||||||
Exception? exception = null;
|
Exception? exception = null;
|
||||||
@@ -93,17 +100,6 @@ internal class CSharpCodeMatcher : ICSharpCodeMatcher
|
|||||||
return new MatchResult(MatchBehaviourHelper.Convert(MatchBehaviour, score), exception);
|
return new MatchResult(MatchBehaviourHelper.Convert(MatchBehaviour, score), exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public string GetCSharpCodeArguments()
|
|
||||||
{
|
|
||||||
return $"new {Name}" +
|
|
||||||
$"(" +
|
|
||||||
$"{MatchBehaviour.GetFullyQualifiedEnumValue()}, " +
|
|
||||||
$"{MatchOperator.GetFullyQualifiedEnumValue()}, " +
|
|
||||||
$"{MappingConverterUtils.ToCSharpCodeArguments(_patterns)}" +
|
|
||||||
$")";
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool IsMatch(dynamic input, string pattern)
|
private bool IsMatch(dynamic input, string pattern)
|
||||||
{
|
{
|
||||||
var isMatchWithString = input is string;
|
var isMatchWithString = input is string;
|
||||||
|
|||||||
@@ -7,6 +7,4 @@ namespace WireMock.Matchers;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <inheritdoc cref="IObjectMatcher"/>
|
/// <inheritdoc cref="IObjectMatcher"/>
|
||||||
/// <inheritdoc cref="IStringMatcher"/>
|
/// <inheritdoc cref="IStringMatcher"/>
|
||||||
public interface ICSharpCodeMatcher : IObjectMatcher, IStringMatcher
|
public interface ICSharpCodeMatcher : IObjectMatcher, IStringMatcher;
|
||||||
{
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user