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(data, filename);
                filenameToDoc[filename] = new WeakReference(doc);
                return(doc);
            }
        }
Exemplo n.º 2
0
        public AsmEdHexDocument GetOrCreate(string filename)
        {
            if (!File.Exists(filename))
            {
                return(null);
            }
            filename = GetFullPath(filename);

            lock (lockObj) {
                AsmEdHexDocument doc;
                if (filenameToDoc.TryGetValue(filename, out doc))
                {
                    return(doc);
                }

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

                doc = new AsmEdHexDocument(data, filename);
                filenameToDoc.Add(filename, doc);
                return(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 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.º 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(string filename)
        {
            filename = GetFullPath(filename);

            lock (lockObj) {
                AsmEdHexDocument doc;
                if (filenameToDoc.TryGetValue(filename, out doc))
                    return doc;

                //TODO: This reads the whole file into memory
                doc = new AsmEdHexDocument(filename);
                filenameToDoc.Add(filename, doc);
                return doc;
            }
        }
Exemplo n.º 7
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.º 8
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(data, filename);
                    filenameToDoc[filename] = new WeakReference(doc);
                    return(doc);
                }
            }
        }
Exemplo n.º 9
0
        public AsmEdHexDocument GetOrCreate(IPEImage peImage)
        {
            var filename = GetFullPath(peImage.FileName);

            lock (lockObj) {
                AsmEdHexDocument doc;
                if (filenameToDoc.TryGetValue(filename, out doc))
                {
                    return(doc);
                }

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

            lock (lockObj) {
                AsmEdHexDocument doc;
                if (filenameToDoc.TryGetValue(filename, out doc))
                    return doc;

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

                doc = new AsmEdHexDocument(data, filename);
                filenameToDoc.Add(filename, doc);
                return doc;
            }
        }
Exemplo n.º 11
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(data, filename);
					filenameToDoc[filename] = new WeakReference(doc);
					return doc;
				}
			}
		}
Exemplo n.º 12
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(data, filename);
				filenameToDoc[filename] = new WeakReference(doc);
				return doc;
			}
		}
Exemplo n.º 13
0
        public AsmEdHexDocument GetOrCreate(IPEImage peImage)
        {
            var filename = GetFullPath(peImage.FileName);

            lock (lockObj) {
                AsmEdHexDocument doc;
                if (filenameToDoc.TryGetValue(filename, out doc))
                    return doc;

                using (var stream = peImage.CreateFullStream()) {
                    var data = stream.ReadAllBytes();
                    doc = new AsmEdHexDocument(data, filename);
                    filenameToDoc.Add(filename, doc);
                    return doc;
                }
            }
        }
Exemplo n.º 14
0
		internal IUndoObject GetUndoObject(AsmEdHexDocument file) {
			return file.UndoObject;
		}
Exemplo n.º 15
0
 internal IUndoObject GetUndoObject(AsmEdHexDocument file)
 {
     return(file.UndoObject);
 }