string GetLinqPadClassName(NamespaceTreeNode namespaceTreeNode)
        {
            string linqpadGeneratedClassName = "UserQuery";

            var classNode =
                namespaceTreeNode.Children.FirstOrDefault(c => Equals(c.Text, linqpadGeneratedClassName));

            if (classNode == null)
            {
                string queryClassId = LinqPadUtil.GetQueryIdentifier(this.assemblyPath);

                var linqPadClass =
                    namespaceTreeNode.Children.FirstOrDefault(c => c.Text.ToString().Contains(queryClassId));

                if (linqPadClass != null)
                {
                    return(linqPadClass.Text.ToString());
                }
            }
            else
            {
                return(classNode.Text.ToString());
            }

            // If the LINQPad query class cannot be found, select something so it loads.
            return(namespaceTreeNode.Children.First().Text.ToString());
        }
        public static void DumpDasm(this object value)
        {
            // Determine the language (Doesn't work when two copies of LINQPad are open)
            Language linqPadSelectedLanguage = LinqPadUtil.GetLanguageForQuery();

            var linqpadSpyPanel = new LinqPadSpyContainer(new Application(), linqPadSelectedLanguage);

            PanelManager.DisplayWpfElement(linqpadSpyPanel, "Decompiled");
        }
        public LinqPadSpyContainer(Application currentApplication, Language decompiledLanguage)
        {
            if (currentApplication == null)
            {
                throw new ArgumentNullException("currentApplication");
            }
            if (decompiledLanguage == null)
            {
                throw new ArgumentNullException("decompiledLanguage");
            }

            this.decompiledLanguage = decompiledLanguage;

            this.currentApplication = currentApplication;

            // Initialize supported ILSpy languages. Values used for the combobox.
            Languages.Initialize(CompositionContainerBuilder.Container);

            this.CurrentAssemblyList = new AssemblyList("LINQPadAssemblyList", this.currentApplication);

            ICSharpCode.ILSpy.App.CompositionContainer = CompositionContainerBuilder.Container;

            CompositionContainerBuilder.Container.ComposeParts(this);

            // A hack to get around the global shared state of the Window object throughout ILSpy.
            ICSharpCode.ILSpy.MainWindow.SpyWindow = this;

            this.spySettings = ILSpySettings.Load();

            this.sessionSettings = new SessionSettings(this.spySettings)
            {
                ActiveAssemblyList = this.CurrentAssemblyList.ListName
            };

            SetUpDataContext();

            this.assemblyPath = LinqPadUtil.GetLastLinqPadQueryAssembly();

            this.decompilerTextView = GetDecompilerTextView();

            InitializeComponent();

            this.mainPane.Content = this.decompilerTextView;

            this.InitToolbar();

            this.Loaded += new RoutedEventHandler(this.MainWindowLoaded);
        }
Exemple #4
0
        public MainWindow()
        {
            this.InitializeComponent();

            this.Content = new LinqPadSpyContainer(Application.Current, LinqPadUtil.GetLanguageForQuery());
        }