mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-14 06:17:11 +01:00
Make CSharpCodeMatcher public (#1337)
This commit is contained in:
@@ -18,7 +18,7 @@ namespace WireMock.Matchers;
|
||||
/// CSharpCode / CS-Script Matcher
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="ICSharpCodeMatcher"/>
|
||||
internal class CSharpCodeMatcher : ICSharpCodeMatcher
|
||||
public class CSharpCodeMatcher : ICSharpCodeMatcher
|
||||
{
|
||||
private const string TemplateForIsMatchWithString = "public class CodeHelper {{ public bool IsMatch(string it) {{ {0} }} }}";
|
||||
|
||||
@@ -63,17 +63,24 @@ internal class CSharpCodeMatcher : ICSharpCodeMatcher
|
||||
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)
|
||||
{
|
||||
return IsMatchInternal(input);
|
||||
}
|
||||
|
||||
public MatchResult IsMatchInternal(object? input)
|
||||
private MatchResult IsMatchInternal(object? input)
|
||||
{
|
||||
var score = MatchScores.Mismatch;
|
||||
Exception? exception = null;
|
||||
@@ -93,17 +100,6 @@ internal class CSharpCodeMatcher : ICSharpCodeMatcher
|
||||
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)
|
||||
{
|
||||
var isMatchWithString = input is string;
|
||||
|
||||
@@ -7,6 +7,4 @@ namespace WireMock.Matchers;
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="IObjectMatcher"/>
|
||||
/// <inheritdoc cref="IStringMatcher"/>
|
||||
public interface ICSharpCodeMatcher : IObjectMatcher, IStringMatcher
|
||||
{
|
||||
}
|
||||
public interface ICSharpCodeMatcher : IObjectMatcher, IStringMatcher;
|
||||
Reference in New Issue
Block a user