3 |
|
using System.Linq; |
4 |
|
using System.Text; |
5 |
|
using System.IO; |
6 |
+ |
using System.Diagnostics; |
7 |
|
|
8 |
|
namespace RomCheater.Serialization |
9 |
|
{ |
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(); } |
55 |
|
binWriter.Write(Convert.ToInt64(value)); |
56 |
|
break; |
57 |
|
} |
58 |
+ |
ResultsWritten++; |
59 |
|
} |
60 |
|
#endregion |
61 |
|
|
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 |
|
} |