Пример #1
0
        public int CompareTo(CodecMatch other)
        {
            if (other?.CodecRegistration == null)
            {
                return(1);
            }
            if (ReferenceEquals(this, other))
            {
                return(0);
            }
            if (WeightedScore == other.WeightedScore)
            {
                return(MatchingParameterCount == other.MatchingParameterCount
          ? MediaType.CompareTo(other.MediaType)
          : MatchingParameterCount.CompareTo(other.MatchingParameterCount));
            }

            return(WeightedScore.CompareTo(other.WeightedScore));
        }
Пример #2
0
        public int CompareTo(CodecMatch other)
        {
            if (other == null || other.CodecRegistration == null)
            {
                return(1);
            }
            if (this == other)
            {
                return(0);
            }
            float weightedScore      = Score * CodecRegistration.MediaType.Quality;
            float otherWeightedScore = other.Score * other.CodecRegistration.MediaType.Quality;

            if (weightedScore == otherWeightedScore)
            {
                return(MatchingParameterCount == other.MatchingParameterCount
                           ? CodecRegistration.MediaType.CompareTo(other.CodecRegistration.MediaType)
                           : MatchingParameterCount.CompareTo(other.MatchingParameterCount));
            }

// highest score is better, so we revert the comparison
            return(weightedScore.CompareTo(otherWeightedScore));
        }