Exemplo n.º 1
0
        public AsmEdHexDocument GetOrCreate(string filename)
        {
            if (!File.Exists(filename))
            {
                return(null);
            }
            filename = GetFullPath(filename);

            lock (lockObj) {
                var doc = TryGet_NoLock(filename);
                if (doc != null)
                {
                    return(doc);
                }

                byte[] data;
                try {
                    data = File.ReadAllBytes(filename);
                }
                catch {
                    return(null);
                }

                doc = new AsmEdHexDocument(undoCommandService, data, filename);
                filenameToDoc[filename] = new WeakReference(doc);
                return(doc);
            }
        }
Exemplo n.º 2
0
		void OnDocumentDirty(AsmEdHexDocument doc) {
			lock (lockObj) {
				object dictObj;
				bool b = filenameToDoc.TryGetValue(doc.Name, out dictObj);
				Debug.Assert(b);
				if (!b)
					return;
				filenameToDoc[doc.Name] = doc;
			}
		}
Exemplo n.º 3
0
 void OnDocumentDirty(AsmEdHexDocument doc)
 {
     lock (lockObj) {
         object dictObj;
         bool   b = filenameToDoc.TryGetValue(doc.Name, out dictObj);
         Debug.Assert(b);
         if (!b)
         {
             return;
         }
         filenameToDoc[doc.Name] = doc;
     }
 }
Exemplo n.º 4
0
		void OnDocumentSaved(AsmEdHexDocument doc) {
			lock (lockObj) {
				object dictObj;
				bool b = filenameToDoc.TryGetValue(doc.Name, out dictObj);
				Debug.Assert(b);
				if (!b)
					return;
				if (dictObj is WeakReference) {
					Debug.Assert(((WeakReference)dictObj).Target == doc);
					return;
				}
				Debug.Assert(doc == dictObj);
				filenameToDoc[doc.Name] = new WeakReference(doc);
			}
		}
Exemplo n.º 5
0
 void OnDocumentSaved(AsmEdHexDocument doc)
 {
     lock (lockObj) {
         object dictObj;
         bool   b = filenameToDoc.TryGetValue(doc.Name, out dictObj);
         Debug.Assert(b);
         if (!b)
         {
             return;
         }
         if (dictObj is WeakReference)
         {
             Debug.Assert(((WeakReference)dictObj).Target == doc);
             return;
         }
         Debug.Assert(doc == dictObj);
         filenameToDoc[doc.Name] = new WeakReference(doc);
     }
 }
Exemplo n.º 6
0
        public AsmEdHexDocument GetOrCreate(IPEImage peImage)
        {
            var filename = GetFullPath(peImage.FileName);

            lock (lockObj) {
                var doc = TryGet_NoLock(filename);
                if (doc != null)
                {
                    return(doc);
                }

                using (var stream = peImage.CreateFullStream()) {
                    var data = stream.ReadAllBytes();
                    doc = new AsmEdHexDocument(undoCommandService, data, filename);
                    filenameToDoc[filename] = new WeakReference(doc);
                    return(doc);
                }
            }
        }
Exemplo n.º 7
0
		public SaveHexOptionsVM(AsmEdHexDocument doc) {
			this.doc = doc;
			this.FileName = doc.Name ?? string.Empty;
		}
Exemplo n.º 8
0
		HexTabSaver(Lazy<IDocumentSaver> documentSaver, AsmEdHexDocument doc) {
			this.documentSaver = documentSaver;
			this.doc = doc;
		}
Exemplo n.º 9
0
 static IUndoObject GetUndoObject(AsmEdHexDocument file) => file.UndoObject;
Exemplo n.º 10
0
 HexTabSaver(Lazy <IDocumentSaver> documentSaver, AsmEdHexDocument doc)
 {
     this.documentSaver = documentSaver;
     this.doc           = doc;
 }
		static IUndoObject GetUndoObject(AsmEdHexDocument file) {
			return file.UndoObject;
		}
Exemplo n.º 12
0
		public AsmEdHexDocument GetOrCreate(IPEImage peImage) {
			var filename = GetFullPath(peImage.FileName);

			lock (lockObj) {
				var doc = TryGet_NoLock(filename);
				if (doc != null)
					return doc;

				using (var stream = peImage.CreateFullStream()) {
					var data = stream.ReadAllBytes();
					doc = new AsmEdHexDocument(undoCommandManager, data, filename);
					filenameToDoc[filename] = new WeakReference(doc);
					return doc;
				}
			}
		}
Exemplo n.º 13
0
		public AsmEdHexDocument GetOrCreate(string filename) {
			if (!File.Exists(filename))
				return null;
			filename = GetFullPath(filename);

			lock (lockObj) {
				var doc = TryGet_NoLock(filename);
				if (doc != null)
					return doc;

				byte[] data;
				try {
					data = File.ReadAllBytes(filename);
				}
				catch {
					return null;
				}

				doc = new AsmEdHexDocument(undoCommandManager, data, filename);
				filenameToDoc[filename] = new WeakReference(doc);
				return doc;
			}
		}
Exemplo n.º 14
0
 static IUndoObject GetUndoObject(AsmEdHexDocument file)
 {
     return(file.UndoObject);
 }