Пример #1
0
        /// <summary>
        /// Starts the decompilation of the given nodes.
        /// The result is displayed in the text view.
        /// If any errors occur, the error message is displayed in the text view, and the task returned by this method completes successfully.
        /// If the operation is cancelled (by starting another decompilation action); the returned task is marked as cancelled.
        /// </summary>
        public Task DecompileAsync(ILSpy.Language language, IEnumerable <ILSpyTreeNode> treeNodes, DecompilationOptions options)
        {
            // Some actions like loading an assembly list cause several selection changes in the tree view,
            // and each of those will start a decompilation action.

            bool isDecompilationScheduled = this.nextDecompilationRun != null;

            if (this.nextDecompilationRun != null)
            {
                this.nextDecompilationRun.TaskCompletionSource.TrySetCanceled();
            }
            this.nextDecompilationRun = new DecompilationContext(language, treeNodes.ToArray(), options);
            var task = this.nextDecompilationRun.TaskCompletionSource.Task;

            if (!isDecompilationScheduled)
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(
                                           delegate {
                    var context = this.nextDecompilationRun;
                    this.nextDecompilationRun = null;
                    if (context != null)
                    {
                        DoDecompile(context, DefaultOutputLengthLimit)
                        .ContinueWith(t => context.TaskCompletionSource.SetFromTask(t)).HandleExceptions();
                    }
                }
                                           ));
            }
            return(task);
        }
Пример #2
0
		/// <summary>
		/// Shows the 'save file dialog', prompting the user to save the decompiled nodes to disk.
		/// </summary>
		public void SaveToDisk(ILSpy.Language language, IEnumerable<ILSpyTreeNode> treeNodes, DecompilationOptions options)
		{
			if (!treeNodes.Any())
				return;
			
			SaveFileDialog dlg = new SaveFileDialog();
			dlg.DefaultExt = language.FileExtension;
			dlg.Filter = language.Name + "|*" + language.FileExtension + "|All Files|*.*";
			dlg.FileName = CleanUpName(treeNodes.First().ToString()) + language.FileExtension;
			if (dlg.ShowDialog() == true) {
				SaveToDisk(new DecompilationContext(language, treeNodes.ToArray(), options), dlg.FileName);
			}
		}
Пример #3
0
        /// <summary>
        /// Starts the decompilation of the given nodes.
        /// The result is displayed in the text view.
        /// </summary>
        public void Decompile(ILSpy.Language language, IEnumerable <ILSpyTreeNode> treeNodes, DecompilationOptions options)
        {
            // Some actions like loading an assembly list cause several selection changes in the tree view,
            // and each of those will start a decompilation action.
            bool isDecompilationScheduled = this.nextDecompilationRun != null;

            this.nextDecompilationRun = new DecompilationContext(language, treeNodes.ToArray(), options);
            if (!isDecompilationScheduled)
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(
                                           delegate {
                    var context = this.nextDecompilationRun;
                    this.nextDecompilationRun = null;
                    if (context != null)
                    {
                        DoDecompile(context, DefaultOutputLengthLimit);
                    }
                }
                                           ));
            }
        }
Пример #4
0
 public void SaveToDisk(ILSpy.Language language, IEnumerable <ILSpyTreeNode> treeNodes, DecompilationOptions options, string fileName)
 {
     SaveToDisk(new DecompilationContext(language, treeNodes.ToArray(), options), fileName);
 }
Пример #5
0
 public DecompilationContext(ILSpy.Language language, ILSpyTreeNode[] treeNodes, DecompilationOptions options)
 {
     this.Language  = language;
     this.TreeNodes = treeNodes;
     this.Options   = options;
 }
Пример #6
0
 public void Decompile(ILSpy.Language language, IEnumerable <ILSpyTreeNode> treeNodes, DecompilationOptions options)
 {
     DecompileAsync(language, treeNodes, options).HandleExceptions();
 }