PartialMapping : SimMetrics.Net

This commit is contained in:
Stef Heyenrath
2017-02-04 21:32:45 +01:00
parent ec2d105db2
commit 44f00cb9fa
22 changed files with 349 additions and 176 deletions

View File

@@ -28,25 +28,23 @@ namespace WireMock.Matchers
/// <summary>
/// Determines whether the specified input is match.
/// </summary>
/// <param name="input">The input.</param>
/// <returns>
/// <c>true</c> if the specified input is match; otherwise, <c>false</c>.
/// </returns>
public bool IsMatch(string input)
/// <param name="input">The input string</param>
/// <returns>A value between 0.0 - 1.0 of the similarity.</returns>
public double IsMatch(string input)
{
if (input == null)
return false;
return MatchScores.Mismatch;
try
{
var nav = new XmlDocument { InnerXml = input }.CreateNavigator();
object result = nav.XPath2Evaluate($"boolean({_pattern})");
return true.Equals(result);
return MatchScores.ToScore(true.Equals(result));
}
catch (Exception)
{
return false;
return MatchScores.Mismatch;
}
}
@@ -58,5 +56,16 @@ namespace WireMock.Matchers
{
return _pattern;
}
/// <summary>
/// Gets the name.
/// </summary>
/// <returns>
/// Name
/// </returns>
public string GetName()
{
return "XPathMatcher";
}
}
}