private AssemblyReferences FindAllReferences(string folderPath, string assemblyName)
        {
            var references = new AssemblyReferences();

            List <AssemblyReferences> allAssemblies = GetAssemblyDetailsForLocation(folderPath);

            foreach (AssemblyReferences assembly in allAssemblies)
            {
                if (assembly.AssemblyName.ToUpper() == assemblyName.ToUpper())
                {
                    references.AssemblyName     = assembly.AssemblyName;
                    references.FullAssemblyName = assembly.FullAssemblyName;
                    references.FilePath         = assembly.FilePath;
                    continue;
                }

                foreach (AssemblyReferences referencedAssembly in assembly.AssembliesReferenced)
                {
                    if (referencedAssembly.AssemblyName.ToUpper() == assemblyName.ToUpper())
                    {
                        references.AssembliesReferenced.Add(assembly);
                    }
                }
            }

            return(references);
        }
Example #2
0
 private void btnSearch_Click(object sender, RoutedEventArgs e)
 {
     _refList.Clear();
     cmbAssemblies.Items.Clear();
     if (txtPath.Text.Length > 0)
     {
         lstResults.Items.Clear();
         AssemblyReferences assembly = _refFinder.FindReferencedAssemblies(txtPath.Text, txtReferenceFind.Text);
         _refList.Add(assembly);
         PopulateComboBox();
     }
 }
Example #3
0
        private void btnLoad_Click(object sender, RoutedEventArgs e)
        {
            _refList.Clear();
            cmbAssemblies.Items.Clear();
            if (txtPath.Text.Length > 0)
            {
                if (txtPath.Text.EndsWith("dll", true, CultureInfo.CurrentCulture) |
                    txtPath.Text.EndsWith("exe", true, CultureInfo.CurrentCulture))
                {
                    AssemblyReferences references = _refFinder.GetAssemblyReferences(txtPath.Text);
                    _refList.Add(references);
                }
                else
                {
                    _refList = _refFinder.GetAllAssemblyDetailsFromPath(txtPath.Text);
                }

                PopulateComboBox();
            }
        }
        private AssemblyReferences GetAssemblyDetails(string filePath)
        {
            var assemblyDetails = new AssemblyReferences();
            var assembly        = Assembly.ReflectionOnlyLoadFrom(filePath);

            assemblyDetails.FilePath         = filePath;
            assemblyDetails.FullAssemblyName = assembly.FullName;
            assemblyDetails.AssemblyName     = assembly.FullName.Split(',')[0];
            var references = assembly.GetReferencedAssemblies();

            foreach (var name in references)
            {
                var assemblyReference = new AssemblyReferences
                {
                    FullAssemblyName = name.FullName,
                    AssemblyName     = name.FullName.Split(',')[0]
                };
                assemblyDetails.AssembliesReferenced.Add(assemblyReference);
            }
            return(assemblyDetails);
        }