/// <summary>
		/// Creates a <see cref="NotifyFileTreeViewCollection.Add"/> instance
		/// </summary>
		/// <param name="file">Added file</param>
		/// <returns></returns>
		public static NotifyFileTreeViewCollectionChangedEventArgs CreateAdd(IDnSpyFileNode file) {
			Debug.Assert(file != null);
			var e = new NotifyFileTreeViewCollectionChangedEventArgs();
			e.Type = NotifyFileTreeViewCollection.Add;
			e.Nodes = new IDnSpyFileNode[] { file };
			return e;
		}
		/// <summary>
		/// Creates a <see cref="NotifyFileTreeViewCollection.Remove"/> instance
		/// </summary>
		/// <param name="files">Removed files</param>
		/// <returns></returns>
		public static NotifyFileTreeViewCollectionChangedEventArgs CreateRemove(IDnSpyFileNode[] files) {
			Debug.Assert(files != null);
			var e = new NotifyFileTreeViewCollectionChangedEventArgs();
			e.Type = NotifyFileTreeViewCollection.Remove;
			e.Nodes = files;
			return e;
		}
		/// <summary>
		/// Creates a <see cref="NotifyFileTreeViewCollection.Clear"/> instance
		/// </summary>
		/// <param name="clearedFiles">All cleared files</param>
		/// <returns></returns>
		public static NotifyFileTreeViewCollectionChangedEventArgs CreateClear(IDnSpyFileNode[] clearedFiles) {
			Debug.Assert(clearedFiles != null);
			var e = new NotifyFileTreeViewCollectionChangedEventArgs();
			e.Type = NotifyFileTreeViewCollection.Clear;
			e.Nodes = clearedFiles;
			return e;
		}
        /// <summary>
        /// Creates a <see cref="NotifyFileTreeViewCollection.Add"/> instance
        /// </summary>
        /// <param name="file">Added file</param>
        /// <returns></returns>
        public static NotifyFileTreeViewCollectionChangedEventArgs CreateAdd(IDnSpyFileNode file)
        {
            Debug.Assert(file != null);
            var e = new NotifyFileTreeViewCollectionChangedEventArgs();

            e.Type  = NotifyFileTreeViewCollection.Add;
            e.Nodes = new IDnSpyFileNode[] { file };
            return(e);
        }
Exemplo n.º 5
0
        public IDnSpyFileNode Create(IFileTreeView fileTreeView, IDnSpyFileNode owner, IDnSpyFile file)
        {
            var myFile = file as MyDnSpyFile;

            if (myFile != null)
            {
                return(new MyDnSpyFileNode(myFile));
            }
            return(null);
        }
Exemplo n.º 6
0
        void OnNodeRemoved(IDnSpyFileNode node)
        {
            var hash = GetSelfAndDnSpyFileNodeChildren(node);

            foreach (TabContentImpl tab in VisibleFirstTabs)
            {
                tab.OnNodesRemoved(hash, () => this.CreateTabContent(new IFileTreeNodeData[0]));
            }
            decompilationCache.Clear(new HashSet <IDnSpyFile>(hash.Select(a => a.DnSpyFile)));
        }
Exemplo n.º 7
0
 public void AddNode(IDnSpyFileNode fileNode, int index)
 {
     if (fileNode == null)
     {
         throw new ArgumentNullException(nameof(fileNode));
     }
     Debug.Assert(!TreeView.Root.DataChildren.Contains(fileNode));
     Debug.Assert(fileNode.TreeNode.Parent == null);
     FileManager.ForceAdd(fileNode.DnSpyFile, false, new AddFileInfo(fileNode, index));
     Debug.Assert(TreeView.Root.DataChildren.Contains(fileNode));
 }
Exemplo n.º 8
0
        public IDnSpyFileNode CreateNode(IDnSpyFileNode owner, IDnSpyFile file)
        {
            foreach (var provider in dnSpyFileNodeProviders)
            {
                var result = provider.Value.Create(this, owner, file);
                if (result != null)
                {
                    return(result);
                }
            }

            return(new UnknownFileNode(file));
        }
Exemplo n.º 9
0
		public static bool HasPENode(IDnSpyFileNode node) {
			if (node == null)
				return false;

			var peImage = node.DnSpyFile.PEImage;

			// Only show the PE node if it was loaded from a file. The hex document is always loaded
			// from a file, so if the PEImage wasn't loaded from the same file, conversion to/from
			// RVA/FileOffset won't work and the wrong data will be displayed, eg. in the .NET
			// storage stream nodes.
			bool loadedFromFile = node.DnSpyFile.Key is FilenameKey;
			return loadedFromFile && peImage != null;
		}
        public IDnSpyFileNode Create(IFileTreeView fileTreeView, IDnSpyFileNode owner, IDnSpyFile file)
        {
            var dnFile = file as IDnSpyDotNetFile;
            if (dnFile != null) {
                Debug.Assert(file.ModuleDef != null);
                if (file.AssemblyDef == null || owner != null)
                    return new ModuleFileNode(dnFile);
                return new AssemblyFileNode(dnFile);
            }
            Debug.Assert(file.AssemblyDef == null && file.ModuleDef == null);
            if (file.PEImage != null)
                return new PEFileNode(file);

            return null;
        }
Exemplo n.º 11
0
 static HashSet <IDnSpyFileNode> GetSelfAndDnSpyFileNodeChildren(IDnSpyFileNode node, HashSet <IDnSpyFileNode> hash = null)
 {
     if (hash == null)
     {
         hash = new HashSet <IDnSpyFileNode>();
     }
     hash.Add(node);
     foreach (var c in node.TreeNode.DataChildren)
     {
         var fileNode = c as IDnSpyFileNode;
         if (fileNode != null)
         {
             GetSelfAndDnSpyFileNodeChildren(fileNode, hash);
         }
     }
     return(hash);
 }
Exemplo n.º 12
0
        public static bool HasPENode(IDnSpyFileNode node)
        {
            if (node == null)
            {
                return(false);
            }

            var peImage = node.DnSpyFile.PEImage;

            // Only show the PE node if it was loaded from a file. The hex document is always loaded
            // from a file, so if the PEImage wasn't loaded from the same file, conversion to/from
            // RVA/FileOffset won't work and the wrong data will be displayed, eg. in the .NET
            // storage stream nodes.
            bool loadedFromFile = node.DnSpyFile.Key is FilenameKey;

            return(loadedFromFile && peImage != null);
        }
Exemplo n.º 13
0
        public IDnSpyFileNode Create(IFileTreeView fileTreeView, IDnSpyFileNode owner, IDnSpyFile file)
        {
            var dnFile = file as IDnSpyDotNetFile;

            if (dnFile != null)
            {
                Debug.Assert(file.ModuleDef != null);
                if (file.AssemblyDef == null || owner != null)
                {
                    return(new ModuleFileNode(dnFile));
                }
                return(new AssemblyFileNode(dnFile));
            }
            Debug.Assert(file.AssemblyDef == null && file.ModuleDef == null);
            if (file.PEImage != null)
            {
                return(new PEFileNode(file));
            }

            return(null);
        }
Exemplo n.º 14
0
 public AddFileInfo(IDnSpyFileNode fileNode, int index)
 {
     this.DnSpyFileNode = fileNode;
     this.Index         = index;
 }
Exemplo n.º 15
0
 public UndoRedoInfo(IDnSpyFileNode node, bool isInUndo, bool isInRedo)
 {
     this.IsInUndo = isInUndo;
     this.IsInRedo = isInRedo;
     this.Node     = node;
 }
Exemplo n.º 16
0
		public RootDnSpyFileNodeCreator(IFileTreeView fileTreeView, IDnSpyFileNode asmNode)
			: this(fileTreeView, asmNode, true) {
		}
Exemplo n.º 17
0
		RootDnSpyFileNodeCreator(IFileTreeView fileTreeView, IDnSpyFileNode fileNode, bool restoreIndex) {
			this.fileTreeView = fileTreeView;
			this.fileNode = fileNode;
			this.restoreIndex = restoreIndex;
		}
Exemplo n.º 18
0
 public RootDnSpyFileNodeCreator(IFileTreeView fileTreeView, IDnSpyFileNode asmNode)
     : this(fileTreeView, asmNode, true)
 {
 }
Exemplo n.º 19
0
 RootDnSpyFileNodeCreator(IFileTreeView fileTreeView, IDnSpyFileNode fileNode, bool restoreIndex)
 {
     this.fileTreeView = fileTreeView;
     this.fileNode     = fileNode;
     this.restoreIndex = restoreIndex;
 }
Exemplo n.º 20
0
 bool CanSearchFile(IDnSpyFileNode node) =>
 SearchSettings.SearchGacAssemblies || !GacInfo.IsGacPath(node.DnSpyFile.Filename);
Exemplo n.º 21
0
		RemoveAssemblyCommand(IFileTreeView fileTreeView, IDnSpyFileNode[] asmNodes) {
			this.savedStates = new RootDnSpyFileNodeCreator[asmNodes.Length];
			for (int i = 0; i < this.savedStates.Length; i++)
				this.savedStates[i] = new RootDnSpyFileNodeCreator(fileTreeView, asmNodes[i]);
		}
Exemplo n.º 22
0
 AddExistingNetModuleToAssemblyCommand(IUndoCommandManager undoCommandManager, IDnSpyFileNode asmNode, IModuleFileNode modNode)
     : base(undoCommandManager, asmNode, modNode, false)
 {
 }
Exemplo n.º 23
0
 protected AddNetModuleToAssemblyCommand(IUndoCommandManager undoCommandManager, IDnSpyFileNode asmNode, IModuleFileNode modNode, bool modNodeWasCreated)
 {
     this.undoCommandManager = undoCommandManager;
     if (!(asmNode is IAssemblyFileNode))
     {
         asmNode = (IAssemblyFileNode)asmNode.TreeNode.Parent.Data;
     }
     this.asmNode           = (IAssemblyFileNode)asmNode;
     this.modNode           = modNode;
     this.modNodeWasCreated = modNodeWasCreated;
 }
Exemplo n.º 24
0
		bool CanSearchFile(IDnSpyFileNode node) {
			return SearchSettings.SearchGacAssemblies || !GacInfo.IsGacPath(node.DnSpyFile.Filename);
		}
Exemplo n.º 25
0
		protected AddNetModuleToAssemblyCommand(IUndoCommandManager undoCommandManager, IDnSpyFileNode asmNode, IModuleFileNode modNode, bool modNodeWasCreated) {
			this.undoCommandManager = undoCommandManager;
			if (!(asmNode is IAssemblyFileNode))
				asmNode = (IAssemblyFileNode)asmNode.TreeNode.Parent.Data;
			this.asmNode = (IAssemblyFileNode)asmNode;
			this.modNode = modNode;
			this.modNodeWasCreated = modNodeWasCreated;
		}
Exemplo n.º 26
0
		AddNewNetModuleToAssemblyCommand(IUndoCommandManager undoCommandManager, IDnSpyFileNode asmNode, IModuleFileNode modNode)
			: base(undoCommandManager, asmNode, modNode, true) {
		}
Exemplo n.º 27
0
 AddNewNetModuleToAssemblyCommand(IUndoCommandManager undoCommandManager, IDnSpyFileNode asmNode, IModuleFileNode modNode)
     : base(undoCommandManager, asmNode, modNode, true)
 {
 }
Exemplo n.º 28
0
		AddExistingNetModuleToAssemblyCommand(IUndoCommandManager undoCommandManager, IDnSpyFileNode asmNode, IModuleFileNode modNode)
			: base(undoCommandManager, asmNode, modNode, false) {
		}
Exemplo n.º 29
0
		public IDnSpyFileNode Create(IFileTreeView fileTreeView, IDnSpyFileNode owner, IDnSpyFile file) {
			var myFile = file as MyDnSpyFile;
			if (myFile != null)
				return new MyDnSpyFileNode(myFile);
			return null;
		}
Exemplo n.º 30
0
			public UndoRedoInfo(IDnSpyFileNode node, bool isInUndo, bool isInRedo) {
				this.IsInUndo = isInUndo;
				this.IsInRedo = isInRedo;
				this.Node = node;
			}