コード例 #1
0
        /// <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);
        }
コード例 #2
0
        /// <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)));
        }
コード例 #3
0
        /// <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());
        }
コード例 #4
0
        /// <inheritdoc cref="IRequestMatcher.GetMatchingScore"/>
        public double GetMatchingScore(RequestMessage requestMessage, RequestMatchResult requestMatchResult)
        {
            double score = MatchBehaviourHelper.Convert(_matchBehaviour, IsMatch(requestMessage));

            return(requestMatchResult.AddScore(GetType(), score));
        }
コード例 #5
0
        /// <inheritdoc cref="IRequestMatcher.GetMatchingScore"/>
        public double GetMatchingScore(RequestMessage requestMessage, RequestMatchResult requestMatchResult)
        {
            double score = IsMatch(requestMessage);

            return(requestMatchResult.AddScore(GetType(), score));
        }
コード例 #6
0
        /// <see cref="IRequestMatcher.GetMatchingScore"/>
        public double GetMatchingScore(IRequestMessage requestMessage, RequestMatchResult requestMatchResult)
        {
            double score = CalculateMatchScore(requestMessage);

            return(requestMatchResult.AddScore(GetType(), score));
        }