Exemplo n.º 1
0
        private void AddReferences(string fileName, HashSet <string> resultFileNames, HashSet <string> visited)
        {
            if (Path.GetFileName(fileName).Equals("mscorlib.dll", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            if (visited.Contains(fileName))
            {
                return;
            }

            visited.Add(fileName);

            if (!resultFileNames.Contains(fileName))
            {
                resultFileNames.Add(fileName);
            }

            Assembly assembly = TryLoadAssembly(fileName);

            if (assembly != null)
            {
                var referencedAssemblies = assembly.GetReferencedAssemblies();
                foreach (var assemblyName in referencedAssemblies)
                {
                    if (!ReferenceChecker.IsFrameworkAssembly(assemblyName))
                    {
                        string referencedFileName = GetAssemblyFileName(assemblyName);

                        if (!string.IsNullOrEmpty(referencedFileName))
                        {
                            AddReferences(referencedFileName, resultFileNames, visited);
                        }
                    }
                }
            }
        }