Beispiel #1
0
        protected override AssemblyReferenceNode CreateAssemblyReferenceNode(string fileName)
        {
            AssemblyReferenceNode node = null;

            try
            {
                node = new ConfigAssemblyReferenceNode(ProjectMgr, fileName);
            }
            catch (System.ArgumentNullException)
            {
            }
            catch (FileNotFoundException)
            {
            }
            catch (System.BadImageFormatException)
            {
            }
            catch (FileLoadException)
            {
            }
            catch (SecurityException)
            {
            }

            return(node);
        }
Beispiel #2
0
        /// <summary>
        /// Checks if an assembly is already added. The method parses all references and compares the full assemblynames, or the location of the assemblies to decide whether two assemblies are the same.
        /// </summary>
        /// <returns>true if the assembly has already been added.</returns>
        protected override bool IsAlreadyAdded()
        {
            ReferenceContainerNode referencesFolder = this.ProjectMgr.GetReferenceContainer() as ReferenceContainerNode;

            Debug.Assert(referencesFolder != null, "Could not find the References node");
            if (referencesFolder == null)
            {
                // Return true so that our caller does not try and add us.
                return(true);
            }

            bool shouldCheckPath = !string.IsNullOrEmpty(this.Url);

            for (HierarchyNode n = referencesFolder.FirstChild; n != null; n = n.NextSibling)
            {
                AssemblyReferenceNode assemblyRefererenceNode = n as AssemblyReferenceNode;
                if (null != assemblyRefererenceNode)
                {
                    // We will check if the full assemblynames are the same or if the Url of the assemblies is the same.
                    if (String.Compare(assemblyRefererenceNode.AssemblyName.FullName, this.assemblyName.FullName, StringComparison.OrdinalIgnoreCase) == 0 ||
                        (shouldCheckPath && CommonUtils.IsSamePath(assemblyRefererenceNode.Url, this.Url)))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #3
0
        public void OnImportsSatisfied()
        {
            this.ReflexilWindow = new ReflexilWindow();

            this.assemblyNodeContextMenu         = new AssemblyNodeContextMenu(eventAggregator);
            this.typeDefinitionNodeContextMenu   = new TypeDefinitionContextMenu(eventAggregator);
            this.resourceNodeContextMenu         = new EmbeddedResourceContextMenu(eventAggregator);
            this.assemblyReferenceContextMenu    = new AssemblyReferenceNode(eventAggregator);
            this.memberDefinitionNodeContextMenu = new MemberDefinitionContextMenu(eventAggregator);
            this.moduleDefinitionNodeContextMenu = new ModuleDefinitionContextMenu(eventAggregator);

            this.eventAggregator.GetEvent <SelectedTreeViewItemChangedEvent>().Subscribe(SetReflexilHandler);
            this.eventAggregator.GetEvent <TreeViewItemCollectionChangedEvent>().Subscribe(LoadAssembliesIntoPlugin);
        }
        protected override AssemblyReferenceNode CreateAssemblyReferenceNode(string fileName)
        {
            AssemblyReferenceNode node = null;

            try {
                node = new PythonAssemblyReferenceNode((PythonProjectNode)this.ProjectMgr, fileName);
            } catch (ArgumentNullException e) {
                Trace.WriteLine("Exception : " + e.Message);
            } catch (FileNotFoundException e) {
                Trace.WriteLine("Exception : " + e.Message);
            } catch (BadImageFormatException e) {
                Trace.WriteLine("Exception : " + e.Message);
            } catch (FileLoadException e) {
                Trace.WriteLine("Exception : " + e.Message);
            } catch (System.Security.SecurityException e) {
                Trace.WriteLine("Exception : " + e.Message);
            }

            return(node);
        }
        protected override AssemblyReferenceNode CreateAssemblyReferenceNode(ProjectElement element)
        {
            AssemblyReferenceNode node = null;

            try
            {
                node = new XSharpAssemblyReferenceNode(this.ProjectMgr, element);
            }
            catch (Exception e)
            {
                XSettings.LogException(e, "CreateAssemblyReferenceNode");
            }
            ReferenceNode existing = null;

            if (isDuplicateNode(node, ref existing))
            {
                AssemblyReferenceNode existingNode = existing as AssemblyReferenceNode;
            }
            return(node);
        }
Beispiel #6
0
        protected override AssemblyReferenceNode CreateAssemblyReferenceNode(ProjectElement element)
        {
            AssemblyReferenceNode node = null;

            try
            {
                node = new XSharpAssemblyReferenceNode(this.ProjectMgr, element);
            }
            catch (Exception e)
            {
                XSharpProjectPackage.Instance.DisplayException(e);
            }
            ReferenceNode existing = null;

            if (isDuplicateNode(node, ref existing))
            {
                AssemblyReferenceNode existingNode = existing as AssemblyReferenceNode;
            }
            return(node);
        }
        /// <summary>
        /// Creates an assembly reference node from a file path.
        /// </summary>
        protected override AssemblyReferenceNode CreateAssemblyReferenceNode(string fileName)
        {
            AssemblyReferenceNode node = null;

            try
            {
                // Ok when file name is a full path or when it doesn't have a DLL extension
                if (!File.Exists(fileName))
                {
                    if (fileName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
                    {
                        fileName = Path.GetFileNameWithoutExtension(fileName);
                    }
                }
                node = new XSharpAssemblyReferenceNode(this.ProjectMgr, fileName);
            }
            catch (Exception e)
            {
                XSettings.LogException(e, "CreateAssemblyReferenceNode");
            }
            return(node);
        }
Beispiel #8
0
 internal OAAssemblyReference(AssemblyReferenceNode assemblyReference) :
     base(assemblyReference)
 {
 }
Beispiel #9
0
 void Decompile(AssemblyReferenceNode node) => decompiler.WriteCommentLine(output, NameUtilities.CleanName(node.AssemblyRef.ToString()));
 internal OAAssemblyReference(AssemblyReferenceNode assemblyReference) :
     base(assemblyReference) {
 }
Beispiel #11
0
        public void Execute(IDataContext context, DelegateExecute nextExecute)
        {
            ISolution solution = context.GetData <ISolution>(JetBrains.ProjectModel.DataContext.DataConstants.SOLUTION);

            if (solution == null)
            {
                return;
            }

            var assemblyExplorerManager = SolutionEx.GetComponent <IAssemblyExplorerManager>(solution);
            var assemblyExplorer        = assemblyExplorerManager.Opened;

            if (assemblyExplorer == null)
            {
                return;
            }

#if DP10
            Assembly asm        = Assembly.GetExecutingAssembly();
            Stream   iconStream = asm.GetManifestResourceStream("JetBrains.DotPeek.Plugins.Console.Console.png");
            var      decoder    = new PngBitmapDecoder(iconStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
            var      icon       = decoder.Frames[0];

            //var icon = new BitmapImage(new Uri(@"pack://application:,,,/JetBrains.DotPeek.Plugins.Console.1.0;Console.png", UriKind.RelativeOrAbsolute));
            //Assembly asm = Assembly.GetExecutingAssembly();
            //Stream iconStream = asm.GetManifestResourceStream("Console.png");
            //BitmapImage bitmap = new BitmapImage();
            //bitmap.BeginInit();
            //bitmap.StreamSource = iconStream;
            //bitmap.EndInit();
            //icon.Source = bitmap;
#elif DP11 || DP12
            IThemedIconManager themedIconManager = SolutionEx.GetComponent <IThemedIconManager>(solution);
            var icon = themedIconManager.GetIcon <ConsoleThemedIcons.Console>().CurrentImageSource;
#endif

            var console       = new ConsoleToolWindow(assemblyExplorerManager);
            var consoleWindow = new Window
            {
                Title   = "Console",
                Icon    = icon,
                Content = console,
                Width   = 640,
                Height  = 520,
                WindowStartupLocation = WindowStartupLocation.CenterScreen,
                ResizeMode            = ResizeMode.CanResize
            };
            consoleWindow.Show();

            // Do we have an assembly node selected somewhere? If so, load the assembly in the console
            var data = context.GetData(TreeModelBrowser.TREE_MODEL_NODES);
            if (data != null)
            {
                var node = data.FirstOrDefault();
                if (node != null)
                {
                    IAssemblyFile     assemblyFile     = null;
                    IAssemblyFileNode assemblyFileNode = node.DataValue as IAssemblyFileNode;
                    if (assemblyFileNode != null)
                    {
                        assemblyFile = ExplorerNodeEx.GetAssemblyFile(assemblyFileNode);
                    }
                    else
                    {
                        AssemblyReferenceNode assemblyReferenceNode = node.DataValue as AssemblyReferenceNode;
                        if (assemblyReferenceNode != null)
                        {
#if DP10
                            IAssembly assemblyResolveResult = ModuleReferencesResolveStoreEx.ResolveResult(assemblyReferenceNode.Reference);
#elif DP11 || DP12
                            IAssembly assemblyResolveResult = ModuleReferencesResolveStoreEx.GetModuleToAssemblyResolveResult(assemblyReferenceNode.Reference);
#endif
                            if (assemblyResolveResult != null)
                            {
                                assemblyFile = Enumerable.FirstOrDefault(assemblyResolveResult.GetFiles());
                            }
                        }
                    }

                    AssemblyInfoCache component = SolutionEx.TryGetComponent <AssemblyInfoCache>(solution);
#if DP10
                    if (component != null && assemblyFile.Location.ExistsFile)
                    {
                        console.LoadAssemblies(new[] { assemblyFile.Location.FullPath });
                    }
#elif DP11 || DP12
                    if (component != null && assemblyFile.Location.ExistsFile && !AssemblyExplorerUtil.AssemblyIsBroken(assemblyFile.Location, component))
                    {
                        console.LoadAssemblies(new[] { assemblyFile.Location.FullPath });
                    }
#endif
                }
            }
        }