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

Comparing trunk/RomCheater/Serialization/SerializationWriter.cs (file contents):
Revision 402 by william, Thu Jun 21 06:30:33 2012 UTC vs.
Revision 446 by william, Sun Jun 2 19:52:03 2013 UTC

# Line 8 | Line 8 | namespace RomCheater.Serialization
8   {
9      public interface ISerializationResultCount
10      {
11 <        int ResultCount { get; }
11 >        int ResultCount { get; }    
12      }
13 +  
14      public abstract class SerializationWriter : ISerializationResultCount, IDisposable
15      {
16 +        private static string CreateFilename(Guid guid)
17 +        {
18 +            if (guid == Guid.Empty)
19 +            {
20 +                return DEFAULT_PATH;
21 +            }
22 +            else
23 +            {
24 +                return string.Format(@"{0}\{1}", DEFAULT_FOLDER, string.Format("{0}.tmp", guid.ToString()));
25 +            }
26 +        }
27          private const string DEFAULT_FOLDER = "tmp";
28          private const string DEFAULT_FILENAME = "SerializedMemoryResults.tmp";
29          private static string DEFAULT_PATH = string.Format(@"{0}\{1}", DEFAULT_FOLDER,DEFAULT_FILENAME);
30 <        public SerializationWriter() : this(DEFAULT_PATH) { }
31 <        protected SerializationWriter(string filename) : this(filename, 0, true) { }
32 <        public SerializationWriter(int resultCount) : this(DEFAULT_PATH, resultCount, true) { }
33 <        public SerializationWriter(string filename, int resultCount, bool delete) { FileName = filename; ResultCount = resultCount; CreateFile(delete); }
30 >        //public SerializationWriter() : this(CreateFilename(Guid.Empty)) {  }
31 >        
32 >        public SerializationWriter(int resultCount, Guid guid) : this(resultCount,guid, true) { }
33 >        public SerializationWriter(int resultCount, Guid guid, bool delete) : this(CreateFilename(guid)) {  ResultCount = resultCount; CreateFile(delete); }
34 >        protected SerializationWriter(Guid guid) : this(0, guid, true) { }
35 >        protected SerializationWriter(string filename) { FileName = filename; }
36  
37          #region ISerializationResultCount members
38 <        public int ResultCount { get; protected set; }        
38 >        public int ResultCount { get; protected set; }
39          #endregion
40          private FileStream fileStream;
41          protected BinaryWriter binWriter;
42          protected string FileName { get; private set; }
43 +
44 +        protected bool Cancelled { get; set; }
45 +        public void CancelRequest() { Cancelled = true; }
46          private bool DeleteResultFile()
47          {
48              try

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines