public override MatchResult Matches(FileInfo file, Dictionary <Type, IFileCache> fileCaches, CancellationToken token) { BitmapFileCache cache = fileCaches[typeof(BitmapFileCache)] as BitmapFileCache; if (cache == null || !cache.IsBitmap) { return(new MatchResult(MatchResultType.NotApplicable, "N/A")); } Bitmap bitmap = cache.Bitmap; PositiveFraction val = new PositiveFraction((uint)bitmap.Width, (uint)bitmap.Height); PositiveFraction paramVal = new PositiveFraction(m_Parameters.Width, m_Parameters.Height); if (paramVal.Denominator == 0) { return(new MatchResult(MatchResultType.NotApplicable, "N/A")); } MatchResultType resultType = CompareUtil.Compare(val, m_Parameters.ComparisonType, paramVal); return(new MatchResult(resultType, val.ToString())); }
public static MatchResultType Compare(PositiveFraction value1, ComparisonType comparisonType, PositiveFraction value2) { switch (comparisonType) { case ComparisonType.LessThan: return(value1 < value2 ? MatchResultType.Yes : MatchResultType.No); case ComparisonType.LessThanOrEqualTo: return(value1 <= value2 ? MatchResultType.Yes : MatchResultType.No); case ComparisonType.EqualTo: return(value1 == value2 ? MatchResultType.Yes : MatchResultType.No); case ComparisonType.GreaterThanOrEqualTo: return(value1 >= value2 ? MatchResultType.Yes : MatchResultType.No); case ComparisonType.GreaterThan: return(value1 > value2 ? MatchResultType.Yes : MatchResultType.No); } return(MatchResultType.Yes); }