banshee r3508 - in trunk/musicbrainz-sharp/src/MusicBrainz: . MusicBrainz



Author: scottp
Date: Fri Mar 21 22:57:34 2008
New Revision: 3508
URL: http://svn.gnome.org/viewvc/banshee?rev=3508&view=rev

Log:
* src/MusicBrainz/MusicBrainz/Query.cs: Add new PerfectMatch() method
  which returns a result if it is the only result with a score of
  100. If no result has a score of 100, or if more than one result
  have a score of 100, null is returned.

Modified:
   trunk/musicbrainz-sharp/src/MusicBrainz/ChangeLog
   trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Query.cs

Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Query.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Query.cs	(original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Query.cs	Fri Mar 21 22:57:34 2008
@@ -115,6 +115,18 @@
             }
         }
         
+        public T PerfectMatch ()
+        {
+            byte tmp_limit = limit;
+            limit = 2;
+            T result1 = Count > 0 ? this [0] : null;
+            T result2 = Count > 1 ? this [1] : null;
+            limit = tmp_limit;
+            
+            return (result1 != null && result1.Score == 100 && (result2 == null || result2.Score < 100))
+                ? result1 : null;
+        }
+        
         public T First ()
         {
             byte tmp_limit = limit;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]