public void AsyncWorker(IFileTabUIContext uiContext, object userData, CancellationTokenSource source)
        {
            var decompileContext = (DecompileContext)userData;

            decompileContext.CancellationTokenSource = source;
            decompileContext.DecompileNodeContext.DecompilationContext.CancellationToken = source.Token;
            decompileFileTabContentFactory.FileTreeNodeDecompiler.Decompile(decompileContext.DecompileNodeContext, nodes);
        }
Exemple #2
0
        public object OnShow(IFileTabUIContext uiContext)
        {
            var ctx    = (ITextEditorUIContext)uiContext;
            var output = new AvalonEditTextOutput();

            Write(output);
            ctx.SetOutput(output, null);
            return(null);
        }
        public object OnShow(IFileTabUIContext uiContext)
        {
            UpdateLanguage();
            var decompileContext = CreateDecompileContext();
            IHighlightingDefinition highlighting;

            decompileContext.CachedOutput = decompileFileTabContentFactory.DecompilationCache.Lookup(decompileContext.DecompileNodeContext.Language, nodes, out highlighting);
            decompileContext.DecompileNodeContext.HighlightingDefinition = highlighting;
            return(decompileContext);
        }
        public object OnShow(IFileTabUIContext uiContext)
        {
            // Get the real type, created by CreateUIContext() above.
            var ctx = (AssemblyChildNodeUIContext)uiContext;

            // You could initialize some stuff, eg. update its DataContext or whatever
            ctx.Initialize("some input");             // pretend we need to initialize something

            return(null);
        }
Exemple #5
0
 public TabContentImpl(FileTabManager fileTabManager, IFileTabUIContextLocator fileTabUIContextLocator, Lazy <IReferenceFileTabContentCreator, IReferenceFileTabContentCreatorMetadata>[] refFactories)
 {
     this.elementScaler = new TabElementScaler();
     this.tabHistory    = new TabHistory();
     this.tabHistory.SetCurrent(new NullFileTabContent(), false);
     this.fileTabManager          = fileTabManager;
     this.fileTabUIContextLocator = fileTabUIContextLocator;
     this.refFactories            = refFactories;
     this.uiContext = new NullFileTabUIContext();
     this.uiObject  = this.uiContext.UIObject;
 }
Exemple #6
0
 public TabContentImpl(FileTabManager fileTabManager, IFileTabUIContextLocator fileTabUIContextLocator, Lazy<IReferenceFileTabContentCreator, IReferenceFileTabContentCreatorMetadata>[] refFactories)
 {
     this.elementScaler = new TabElementScaler();
     this.tabHistory = new TabHistory();
     this.tabHistory.SetCurrent(new NullFileTabContent(), false);
     this.fileTabManager = fileTabManager;
     this.fileTabUIContextLocator = fileTabUIContextLocator;
     this.refFactories = refFactories;
     this.uiContext = new NullFileTabUIContext();
     this.uiObject = this.uiContext.UIObject;
 }
 public TabContentImpl(FileTabManager fileTabManager, IFileTabUIContextLocator fileTabUIContextLocator, Lazy <IReferenceFileTabContentProvider, IReferenceFileTabContentProviderMetadata>[] referenceFileTabContentProviders, Lazy <IDefaultFileTabContentProvider, IDefaultFileTabContentProviderMetadata>[] defaultFileTabContentProviders)
 {
     this.elementScaler = new TabElementScaler();
     this.tabHistory    = new TabHistory();
     this.tabHistory.SetCurrent(new NullFileTabContent(), false);
     this.fileTabManager                   = fileTabManager;
     this.fileTabUIContextLocator          = fileTabUIContextLocator;
     this.referenceFileTabContentProviders = referenceFileTabContentProviders;
     this.defaultFileTabContentProviders   = defaultFileTabContentProviders;
     this.uiContext = new NullFileTabUIContext();
     this.uiObject  = this.uiContext.UIObject;
 }
        public bool CanStartAsyncWorker(IFileTabUIContext uiContext, object userData)
        {
            var decompileContext = (DecompileContext)userData;

            if (decompileContext.CachedOutput != null)
            {
                return(false);
            }

            var uiCtx = (ITextEditorUIContext)uiContext;

            uiCtx.ShowCancelButton(() => decompileContext.CancellationTokenSource.Cancel(), dnSpy_Resources.Decompiling);
            return(true);
        }
        public void EndAsyncShow(IFileTabUIContext uiContext, object userData, IAsyncShowResult result)
        {
            var decompileContext = (DecompileContext)userData;
            var uiCtx            = (ITextEditorUIContext)uiContext;

            IHighlightingDefinition highlighting;

            if (decompileContext.DecompileNodeContext.HighlightingDefinition != null)
            {
                highlighting = decompileContext.DecompileNodeContext.HighlightingDefinition;
            }
            else if (decompileContext.DecompileNodeContext.HighlightingExtension != null)
            {
                highlighting = HighlightingManager.Instance.GetDefinitionByExtension(decompileContext.DecompileNodeContext.HighlightingExtension);
            }
            else
            {
                highlighting = decompileContext.DecompileNodeContext.Language.GetHighlightingDefinition();
            }

            AvalonEditTextOutput output;

            if (result.IsCanceled)
            {
                output = new AvalonEditTextOutput();
                output.Write(dnSpy_Resources.DecompilationCanceled, TextTokenKind.Error);
            }
            else if (result.Exception != null)
            {
                output = new AvalonEditTextOutput();
                output.Write(dnSpy_Resources.DecompilationException, TextTokenKind.Error);
                output.WriteLine();
                output.Write(result.Exception.ToString(), TextTokenKind.Text);
            }
            else
            {
                output = decompileContext.CachedOutput;
                if (output == null)
                {
                    output = (AvalonEditTextOutput)decompileContext.DecompileNodeContext.Output;
                    decompileFileTabContentFactory.DecompilationCache.Cache(decompileContext.DecompileNodeContext.Language, nodes, output, highlighting);
                }
            }

            if (result.CanShowOutput)
            {
                uiCtx.SetOutput(output, highlighting);
            }
        }
        public void EndAsyncShow(IFileTabUIContext uiContext, object userData, IAsyncShowResult result)
        {
            var decompileContext = (DecompileContext)userData;
            var uiCtx = (ITextEditorUIContext)uiContext;

            IHighlightingDefinition highlighting;
            if (decompileContext.DecompileNodeContext.HighlightingDefinition != null)
                highlighting = decompileContext.DecompileNodeContext.HighlightingDefinition;
            else if (decompileContext.DecompileNodeContext.HighlightingExtension != null)
                highlighting = HighlightingManager.Instance.GetDefinitionByExtension(decompileContext.DecompileNodeContext.HighlightingExtension);
            else
                highlighting = decompileContext.DecompileNodeContext.Language.GetHighlightingDefinition();

            AvalonEditTextOutput output;
            if (result.IsCanceled) {
                output = new AvalonEditTextOutput();
                output.Write(dnSpy_Resources.DecompilationCanceled, TextTokenKind.Error);
            }
            else if (result.Exception != null) {
                output = new AvalonEditTextOutput();
                output.Write(dnSpy_Resources.DecompilationException, TextTokenKind.Error);
                output.WriteLine();
                output.Write(result.Exception.ToString(), TextTokenKind.Text);
            }
            else {
                output = decompileContext.CachedOutput;
                if (output == null) {
                    output = (AvalonEditTextOutput)decompileContext.DecompileNodeContext.Output;
                    decompileFileTabContentFactory.DecompilationCache.Cache(decompileContext.DecompileNodeContext.Language, nodes, output, highlighting);
                }
            }

            if (result.CanShowOutput)
                uiCtx.SetOutput(output, highlighting);
        }
 public ShowContext(IFileTabUIContext uiCtx, bool isRefresh)
 {
     this.UIContext = uiCtx;
     this.IsRefresh = isRefresh;
 }
		public object OnShow(IFileTabUIContext uiContext) {
			return null;
		}
Exemple #13
0
 public object OnShow(IFileTabUIContext uiContext)
 {
     var ctx = (ITextEditorUIContext)uiContext;
     var output = new AvalonEditTextOutput();
     Write(output);
     ctx.SetOutput(output, null);
     return null;
 }
		public object OnShow(IFileTabUIContext uiContext) {
			// Get the real type, created by CreateUIContext() above.
			var ctx = (AssemblyChildNodeUIContext)uiContext;

			// You could initialize some stuff, eg. update its DataContext or whatever
			ctx.Initialize("some input"); // pretend we need to initialize something

			return null;
		}
 public object OnShow(IFileTabUIContext uiContext)
 {
     UpdateLanguage();
     var decompileContext = CreateDecompileContext();
     IHighlightingDefinition highlighting;
     decompileContext.CachedOutput = decompileFileTabContentFactory.DecompilationCache.Lookup(decompileContext.DecompileNodeContext.Language, nodes, out highlighting);
     decompileContext.DecompileNodeContext.HighlightingDefinition = highlighting;
     return decompileContext;
 }
        public bool CanStartAsyncWorker(IFileTabUIContext uiContext, object userData)
        {
            var decompileContext = (DecompileContext)userData;
            if (decompileContext.CachedOutput != null)
                return false;

            var uiCtx = (ITextEditorUIContext)uiContext;
            uiCtx.ShowCancelButton(() => decompileContext.CancellationTokenSource.Cancel(), dnSpy_Resources.Decompiling);
            return true;
        }
 public void AsyncWorker(IFileTabUIContext uiContext, object userData, CancellationTokenSource source)
 {
     var decompileContext = (DecompileContext)userData;
     decompileContext.CancellationTokenSource = source;
     decompileContext.DecompileNodeContext.DecompilationContext.CancellationToken = source.Token;
     decompileFileTabContentFactory.FileTreeNodeDecompiler.Decompile(decompileContext.DecompileNodeContext, nodes);
 }
Exemple #18
0
 public ShowContext(IFileTabUIContext uiCtx, bool isRefresh)
 {
     this.UIContext = uiCtx;
     this.IsRefresh = isRefresh;
 }
 public object OnShow(IFileTabUIContext uiContext)
 {
     return(null);
 }