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

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

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

revision 401 by william, Thu Jun 21 05:14:38 2012 UTC revision 402 by william, Thu Jun 21 06:30:33 2012 UTC
# Line 6  using System.IO; Line 6  using System.IO;
6    
7  namespace RomCheater.Serialization  namespace RomCheater.Serialization
8  {  {
9      public interface ISerializationWriter      public interface ISerializationResultCount
10      {      {
11          int ResultCount { get; }          int ResultCount { get; }
12      }      }
13      public abstract class SerializationWriter : ISerializationWriter, IDisposable      public abstract class SerializationWriter : ISerializationResultCount, IDisposable
14      {      {
15          private const string DEFAULT_FOLDER = "tmp";          private const string DEFAULT_FOLDER = "tmp";
16          private const string DEFAULT_FILENAME = "SerializedMemoryResults.tmp";          private const string DEFAULT_FILENAME = "SerializedMemoryResults.tmp";
17          private static string DEFAULT_PATH = string.Format(@"{0}\{1}", DEFAULT_FOLDER,DEFAULT_FILENAME);          private static string DEFAULT_PATH = string.Format(@"{0}\{1}", DEFAULT_FOLDER,DEFAULT_FILENAME);
18          public SerializationWriter() : this(DEFAULT_PATH) { }          public SerializationWriter() : this(DEFAULT_PATH) { }
19          protected SerializationWriter(string filename) : this(filename, 0) { }          protected SerializationWriter(string filename) : this(filename, 0, true) { }
20          public SerializationWriter(int resultCount) : this(DEFAULT_PATH, resultCount) { }          public SerializationWriter(int resultCount) : this(DEFAULT_PATH, resultCount, true) { }
21          public SerializationWriter(string filename, int resultCount) { FileName = filename; ResultCount = resultCount; CreateFile(); }          public SerializationWriter(string filename, int resultCount, bool delete) { FileName = filename; ResultCount = resultCount; CreateFile(delete); }
22    
23          #region ISerializationWriter members          #region ISerializationResultCount members
24          public int ResultCount { get; protected set; }          public int ResultCount { get; protected set; }        
           
25          #endregion          #endregion
26          private FileStream fileStream;          private FileStream fileStream;
27          protected BinaryWriter binWriter;          protected BinaryWriter binWriter;
# Line 44  namespace RomCheater.Serialization Line 43  namespace RomCheater.Serialization
43                  return false;                  return false;
44              }              }
45          }          }
46          private void CreateFile()          private void CreateFile(bool delete)
47          {          {
48              DeleteResultFile();              if (delete)
49                    DeleteResultFile();
50              FileInfo fi = new FileInfo(FileName);              FileInfo fi = new FileInfo(FileName);
51              if (!fi.Exists)              if (!fi.Exists)
52              {              {

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

  ViewVC Help
Powered by ViewVC 1.1.22