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

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

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

revision 402 by william, Thu Jun 21 06:30:33 2012 UTC revision 405 by william, Thu Jun 21 14:38:54 2012 UTC
# Line 3  using System.Collections.Generic; Line 3  using System.Collections.Generic;
3  using System.Linq;  using System.Linq;
4  using System.Text;  using System.Text;
5  using System.IO;  using System.IO;
6    using System.Diagnostics;
7    
8  namespace RomCheater.Serialization  namespace RomCheater.Serialization
9  {  {
# Line 12  namespace RomCheater.Serialization Line 13  namespace RomCheater.Serialization
13      }      }
14      public class SearchResultWriter : SerializationWriter, ISearchResultWriter      public class SearchResultWriter : SerializationWriter, ISearchResultWriter
15      {      {
16    
17            private int ResultsWritten = 0;
18    
19          public SearchResultWriter() : base() { }          public SearchResultWriter() : base() { }
20          public SearchResultWriter(int resultCount) : base(resultCount) { WriteHeader(); }          public SearchResultWriter(int resultCount) : base(resultCount) { WriteHeader(); }
21          public SearchResultWriter(string filename) : base(filename) { WriteHeader(); }          public SearchResultWriter(string filename) : base(filename) { WriteHeader(); }
# Line 51  namespace RomCheater.Serialization Line 55  namespace RomCheater.Serialization
55                      binWriter.Write(Convert.ToInt64(value));                      binWriter.Write(Convert.ToInt64(value));
56                      break;                      break;
57              }              }
58                ResultsWritten++;
59          }          }
60          #endregion          #endregion
61    
# Line 63  namespace RomCheater.Serialization Line 68  namespace RomCheater.Serialization
68              // write count (int)              // write count (int)
69              binWriter.Write(ResultCount);              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  }  }

Legend:
Removed from v.402  
changed lines
  Added in v.405

  ViewVC Help
Powered by ViewVC 1.1.22