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

Comparing trunk/RomCheater/Serialization/SerializationReader.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

--- trunk/RomCheater/Serialization/SerializationReader.cs	2012/06/21 06:30:33	402
+++ trunk/RomCheater/Serialization/SerializationReader.cs	2013/06/02 19:52:03	446
@@ -8,12 +8,28 @@ namespace RomCheater.Serialization
 {
     public abstract class SerializationReader : ISerializationResultCount, IDisposable
     {
+         private static string CreateFilename(Guid guid)
+        {
+            if (guid == Guid.Empty)
+            {
+                return DEFAULT_PATH;
+            }
+            else
+            {
+                return string.Format(@"{0}\{1}", DEFAULT_FOLDER, string.Format("{0}.tmp", guid.ToString()));
+            }
+        }
         private const string DEFAULT_FOLDER = "tmp";
         private const string DEFAULT_FILENAME = "SerializedMemoryResults.tmp";
         private static string DEFAULT_PATH = string.Format(@"{0}\{1}", DEFAULT_FOLDER, DEFAULT_FILENAME);
-        public SerializationReader() : this(DEFAULT_PATH) { }
-        protected SerializationReader(string filename) { FileName = filename; CreateReader(); }
+        //public SerializationReader() : this(CreateFilename(Guid.Empty)) { CreateReader(Guid.Empty); }
+        public SerializationReader(Guid guid) : this(CreateFilename(guid)) { CreateReader(guid); } 
+        protected SerializationReader(string filename) { FileName = filename; }
+
+
+        protected bool Cancelled { get; set; }
 
+        public void CancelRequest() { Cancelled = true; }
 
         #region ISerializationResultCount members
         public int ResultCount { get; protected set; }
@@ -21,8 +37,9 @@ namespace RomCheater.Serialization
         private FileStream fileStream;
         protected BinaryReader binReader;
         protected string FileName { get; private set; }
-        private void CreateReader()
+        private void CreateReader(Guid guid)
         {
+            if (Cancelled) { return; }
             fileStream = new FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.Read);
             binReader = new BinaryReader(fileStream);
         }