private double GetMatchScore(ParsedMedia searchedMedia, ParsedMedia parsedSearchResult) { double matchScore = 1.0; var maximalDistances = new[] { new { Name = nameof(ParsedMedia.Title), Ratio = 0.2 }, new { Name = nameof(ParsedMedia.Season), Ratio = 0.0 }, new { Name = nameof(ParsedMedia.Episode), Ratio = 0.0 }, new { Name = nameof(ParsedMedia.Quality), Ratio = 0.5 }, new { Name = nameof(ParsedMedia.Resolution), Ratio = 0.0 } }; Type type = typeof(ParsedMedia); foreach (var maximalDistance in maximalDistances) { string searchedMediaPropertyValue = type.GetProperty(maximalDistance.Name).GetValue(searchedMedia) as string; string searchResultPropertyValue = type.GetProperty(maximalDistance.Name).GetValue(parsedSearchResult) as string; if (!LevenshteinDistance.CheckLevenshteinDistanceRatio(searchedMediaPropertyValue, searchResultPropertyValue, maximalDistance.Ratio)) { matchScore -= 1.0 - maximalDistance.Ratio; } } return(matchScore); }