ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/RomCheater/Serialization/SearchResultWriter.cs
(Generate patch)

Comparing trunk/RomCheater/Serialization/SearchResultWriter.cs (file contents):
Revision 404 by william, Thu Jun 21 06:30:33 2012 UTC vs.
Revision 405 by william, Thu Jun 21 14:38:54 2012 UTC

# Line 3 | Line 3 | using System.Collections.Generic;
3   using System.Linq;
4   using System.Text;
5   using System.IO;
6 + using System.Diagnostics;
7  
8   namespace RomCheater.Serialization
9   {
# Line 12 | Line 13 | namespace RomCheater.Serialization
13      }
14      public class SearchResultWriter : SerializationWriter, ISearchResultWriter
15      {
16 +
17 +        private int ResultsWritten = 0;
18 +
19          public SearchResultWriter() : base() { }
20          public SearchResultWriter(int resultCount) : base(resultCount) { WriteHeader(); }
21          public SearchResultWriter(string filename) : base(filename) { WriteHeader(); }
# Line 51 | Line 55 | namespace RomCheater.Serialization
55                      binWriter.Write(Convert.ToInt64(value));
56                      break;
57              }
58 +            ResultsWritten++;
59          }
60          #endregion
61  
# Line 63 | Line 68 | namespace RomCheater.Serialization
68              // write count (int)
69              binWriter.Write(ResultCount);
70          }
71 +
72 +        protected override void Dispose(bool disposing)
73 +        {
74 +            base.Dispose(disposing);
75 +            // ensure ResultCount and ResultsWritten are equal
76 +            if (ResultCount != ResultsWritten)
77 +            {
78 +                throw new InvalidOperationException(string.Format("ResultCount does not match ResultsWritten: 0x{0:x8} != 0x{1:x8}", ResultCount, ResultsWritten));
79 +            }            
80 +        }
81      }
82   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines