/// <summary> /// Determines whether the specified RequestMessage is match. /// </summary> /// <param name="requestMessage">The RequestMessage.</param> /// <param name="requestMatchResult">The RequestMatchResult.</param> /// <returns> /// A value between 0.0 - 1.0 of the similarity. /// </returns> public double GetMatchingScore(RequestMessage requestMessage, RequestMatchResult requestMatchResult) { double score = IsMatch(requestMessage); requestMatchResult.TotalScore += score; requestMatchResult.TotalNumber++; return(score); }
/// <inheritdoc cref="IRequestMatcher.GetMatchingScore"/> public double GetMatchingScore(RequestMessage requestMessage, RequestMatchResult requestMatchResult) { if (!RequestMatchers.Any()) { return(MatchScores.Mismatch); } if (_type == CompositeMatcherType.And) { return(RequestMatchers.Average(requestMatcher => requestMatcher.GetMatchingScore(requestMessage, requestMatchResult))); } return(RequestMatchers.Max(requestMatcher => requestMatcher.GetMatchingScore(requestMessage, requestMatchResult))); }
/// <summary> /// Determines whether the specified RequestMessage is match. /// </summary> /// <param name="requestMessage">The RequestMessage.</param> /// <param name="requestMatchResult">The RequestMatchResult.</param> /// <returns> /// A value between 0.0 - 1.0 of the similarity. /// </returns> public double GetMatchingScore(RequestMessage requestMessage, RequestMatchResult requestMatchResult) { var list = new List <double>(); if (_type == CompositeMatcherType.And) { foreach (var requestMatcher in RequestMatchers) { double score = requestMatcher.GetMatchingScore(requestMessage, requestMatchResult); list.Add(score); } return(list.Sum() / list.Count); } foreach (var requestMatcher in RequestMatchers) { double score = requestMatcher.GetMatchingScore(requestMessage, requestMatchResult); list.Add(score); } return(list.Max()); }
/// <inheritdoc cref="IRequestMatcher.GetMatchingScore"/> public double GetMatchingScore(RequestMessage requestMessage, RequestMatchResult requestMatchResult) { double score = MatchBehaviourHelper.Convert(_matchBehaviour, IsMatch(requestMessage)); return(requestMatchResult.AddScore(GetType(), score)); }
/// <inheritdoc cref="IRequestMatcher.GetMatchingScore"/> public double GetMatchingScore(RequestMessage requestMessage, RequestMatchResult requestMatchResult) { double score = IsMatch(requestMessage); return(requestMatchResult.AddScore(GetType(), score)); }
/// <see cref="IRequestMatcher.GetMatchingScore"/> public double GetMatchingScore(IRequestMessage requestMessage, RequestMatchResult requestMatchResult) { double score = CalculateMatchScore(requestMessage); return(requestMatchResult.AddScore(GetType(), score)); }