/[RomCheater]/trunk/RomCheater/Serialization/SearchResultReader.cs
ViewVC logotype

Diff of /trunk/RomCheater/Serialization/SearchResultReader.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/RomCheater/Serialization/SearchResultReader.cs	2013/05/28 20:44:13	443
+++ trunk/RomCheater/Serialization/SearchResultReader.cs	2013/06/02 18:56:41	444
@@ -14,9 +14,10 @@
     }
     public class SearchResultReader : SerializationReader, ISearchResultReader
     {
-        public SearchResultReader() : base() { ReadHeader(); }
+        //public SearchResultReader() : base() { ReadHeader(); }
+        public SearchResultReader(Guid guid) : base(guid) { ReadHeader(guid); }
 
-        private void ReadHeader()
+        private void ReadHeader(Guid guid)
         {
             try
             {
@@ -30,9 +31,25 @@
                 }
                 // version (int)
                 int version = binReader.ReadInt32();
-                if (version != 1)
+
+                if (version == 1)
+                {
+                    // do nothing
+                }
+                else if (version == 2)
+                {
+                    int guid_array_length = binReader.ReadInt32();
+                    byte[] guid_array = new byte[guid_array_length];
+                    binReader.Read(guid_array, 0, guid_array_length);
+                    Guid g = new Guid(guid_array);
+                    if (g != guid)
+                    {
+                        throw new InvalidOperationException(string.Format("Encountered wrong search results guid: read '{1}' excpected '{2}'", g.ToString(), guid.ToString()));
+                    }
+                }
+                else
                 {
-                    throw new InvalidOperationException(string.Format("Encountered unexpected version: {0} expected: {1}", version, 1));
+                    throw new InvalidOperationException(string.Format("Encountered unexpected version: {0} expected: {1} or {2}", version, 1, 2));
                 }
                 // resultcount
                 int resultcount = binReader.ReadInt32();

 

  ViewVC Help
Powered by ViewVC 1.1.22