/[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 446 by william, Sun Jun 2 19:52:03 2013 UTC revision 448 by william, Sun Jun 2 20:22:04 2013 UTC
# Line 13  namespace RomCheater.Serialization Line 13  namespace RomCheater.Serialization
13        
14      public abstract class SerializationWriter : ISerializationResultCount, IDisposable      public abstract class SerializationWriter : ISerializationResultCount, IDisposable
15      {      {
16          private static string CreateFilename(Guid guid)          private void CreateFilename(Guid guid)
17          {          {
18              if (guid == Guid.Empty)              if (guid == Guid.Empty)
19              {              {
20                  return DEFAULT_PATH;                  if (this.TemporaryFolder != string.Empty)
21                    {
22                        FileName= string.Format(@"{0}\{1}\{2}", DEFAULT_FOLDER, TemporaryFolder, DEFAULT_FILENAME);
23                    }
24                    else
25                    {
26                        FileName = string.Format(@"{0}\{1}", DEFAULT_FOLDER, DEFAULT_FILENAME);
27                    }
28                    
29              }              }
30              else              else
31              {              {
32                  return string.Format(@"{0}\{1}", DEFAULT_FOLDER, string.Format("{0}.tmp", guid.ToString()));                  if (this.TemporaryFolder != string.Empty)
33                    {
34                        FileName = string.Format(@"{0}\{1}\{2}", DEFAULT_FOLDER, TemporaryFolder, string.Format("{0}.tmp", guid.ToString()));
35                    }
36                    else
37                    {
38                        FileName = string.Format(@"{0}\{1}", DEFAULT_FOLDER, string.Format("{0}.tmp", guid.ToString()));
39                    }
40              }              }
41          }          }
42          private const string DEFAULT_FOLDER = "tmp";          protected const string DEFAULT_FOLDER = "tmp";
43          private const string DEFAULT_FILENAME = "SerializedMemoryResults.tmp";          private const string DEFAULT_FILENAME = "SerializedMemoryResults.tmp";
44          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);
45    
46            protected virtual string TemporaryFolder { get { return string.Empty; } }
47    
48          //public SerializationWriter() : this(CreateFilename(Guid.Empty)) {  }          //public SerializationWriter() : this(CreateFilename(Guid.Empty)) {  }
49            
50    
51            public static void CleanupTemporarySearchResultFiles()
52            {
53                DirectoryInfo di = new DirectoryInfo(string.Format(@"{0}\{1}", DEFAULT_FOLDER, SearchResultsConstants.SearchResultsFolder));
54                if (di.Exists)
55                {
56                    di.Delete(true);
57                }
58            }
59    
60    
61          public SerializationWriter(int resultCount, Guid guid) : this(resultCount,guid, true) { }          public SerializationWriter(int resultCount, Guid guid) : this(resultCount,guid, true) { }
62          public SerializationWriter(int resultCount, Guid guid, bool delete) : this(CreateFilename(guid)) {  ResultCount = resultCount; CreateFile(delete); }          public SerializationWriter(int resultCount, Guid guid, bool delete) { CreateFilename(guid); ResultCount = resultCount; CreateFile(delete); }
63          protected SerializationWriter(Guid guid) : this(0, guid, true) { }          //protected SerializationWriter(Guid guid) : this(0, guid, true) { }
64          protected SerializationWriter(string filename) { FileName = filename; }          //protected SerializationWriter(string filename) { FileName = filename; }
65    
66          #region ISerializationResultCount members          #region ISerializationResultCount members
67          public int ResultCount { get; protected set; }          public int ResultCount { get; protected set; }
68          #endregion          #endregion
69          private FileStream fileStream;          protected FileStream fileStream;
70          protected BinaryWriter binWriter;          protected BinaryWriter binWriter;
71          protected string FileName { get; private set; }          protected string FileName { get; private set; }
72    

Legend:
Removed from v.446  
changed lines
  Added in v.448

  ViewVC Help
Powered by ViewVC 1.1.22