RemoveDuplicates() private méthode

private RemoveDuplicates ( ) : void
Résultat void
        /// <summary>
        /// Traverses the specified base directory including all sub-directories, generating a list of assemblies that can be
        /// scanned for handlers, a list of skipped files, and a list of errors that occurred while scanning.
        /// Scanned files may be skipped when they're either not a .NET assembly, or if a reflection-only load of the .NET
        /// assembly reveals that it does not reference NServiceBus.
        /// </summary>
        public AssemblyScannerResults GetScannableAssemblies()
        {
            var results   = new AssemblyScannerResults();
            var processed = new Dictionary <string, bool>(StringComparer.OrdinalIgnoreCase);

            if (assemblyToScan != null)
            {
                var assemblyPath = AssemblyPath(assemblyToScan);
                ScanAssembly(assemblyPath, results, processed);
                return(results);
            }

            foreach (var assemblyFile in ScanDirectoryForAssemblyFiles(baseDirectoryToScan, ScanNestedDirectories))
            {
                ScanAssembly(assemblyFile.FullName, results, processed);
            }

            // This extra step is to ensure unobtrusive message types are included in the Types list.
            var list = GetHandlerMessageTypes(results.Types);

            results.Types.AddRange(list);

            results.RemoveDuplicates();

            return(results);
        }
Exemple #2
0
        /// <summary>
        /// Traverses the specified base directory including all sub-directories, generating a list of assemblies that can be
        /// scanned for handlers, a list of skipped files, and a list of errors that occurred while scanning.
        /// Scanned files may be skipped when they're either not a .NET assembly, or if a reflection-only load of the .NET
        /// assembly reveals that it does not reference NServiceBus.
        /// </summary>
        public AssemblyScannerResults GetScannableAssemblies()
        {
            var results = new AssemblyScannerResults();

            if (assemblyToScan != null)
            {
                var assemblyPath = AssemblyPath(assemblyToScan);
                ScanAssembly(assemblyPath, results);
                return(results);
            }

            if (IncludeAppDomainAssemblies)
            {
                var matchingAssembliesFromAppDomain = MatchingAssembliesFromAppDomain();

                foreach (var assembly in matchingAssembliesFromAppDomain)
                {
                    ScanAssembly(AssemblyPath(assembly), results);
                }
            }

            foreach (var assemblyFile in ScanDirectoryForAssemblyFiles())
            {
                ScanAssembly(assemblyFile.FullName, results);
            }

            // This extra step is to ensure unobtrusive message types are included in the Types list.
            var list = GetHandlerMessageTypes(results.Types).ToList();

            results.Types.AddRange(list);

            results.RemoveDuplicates();

            return(results);
        }
        /// <summary>
        /// Traverses the specified base directory including all sub-directories, generating a list of assemblies that can be
        /// scanned for handlers, a list of skipped files, and a list of errors that occurred while scanning.
        /// Scanned files may be skipped when they're either not a .NET assembly, or if a reflection-only load of the .NET
        /// assembly reveals that it does not reference NServiceBus.
        /// </summary>
        public AssemblyScannerResults GetScannableAssemblies()
        {
            var results = new AssemblyScannerResults();
            var processed = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase);

            if (assemblyToScan != null)
            {
                var assemblyPath = AssemblyPath(assemblyToScan);
                ScanAssembly(assemblyPath, results, processed);
                return results;
            }

            foreach (var assemblyFile in ScanDirectoryForAssemblyFiles(baseDirectoryToScan, ScanNestedDirectories))
            {
                ScanAssembly(assemblyFile.FullName, results, processed);
            }

            // This extra step is to ensure unobtrusive message types are included in the Types list.
            var list = GetHandlerMessageTypes(results.Types);
            results.Types.AddRange(list);

            results.RemoveDuplicates();

            return results;
        }
        /// <summary>
        /// Traverses the specified base directory including all sub-directories, generating a list of assemblies that can be
        /// scanned for handlers, a list of skipped files, and a list of errors that occurred while scanning.
        /// Scanned files may be skipped when they're either not a .NET assembly, or if a reflection-only load of the .NET
        /// assembly reveals that it does not reference NServiceBus.
        /// </summary>
        public AssemblyScannerResults GetScannableAssemblies()
        {
            var results = new AssemblyScannerResults();

            if (assemblyToScan != null)
            {
                ScanAssembly(assemblyToScan, results);
                return(results);
            }

            if (ScanAppDomainAssemblies)
            {
                var appDomainAssemblies = AppDomain.CurrentDomain.GetAssemblies();
                foreach (var assembly in appDomainAssemblies)
                {
                    if (!assembly.IsDynamic)
                    {
                        ScanAssembly(assembly, results);
                    }
                }
            }

            var processed = new Dictionary <string, bool>(StringComparer.OrdinalIgnoreCase);

            foreach (var assemblyFile in ScanDirectoryForAssemblyFiles(baseDirectoryToScan, ScanNestedDirectories))
            {
                Assembly assembly;
                if (TryLoadScannableAssembly(assemblyFile.FullName, results, processed, out assembly))
                {
                    ScanAssembly(assembly, results);
                }
            }

            // This extra step is to ensure unobtrusive message types are included in the Types list.
            var list = GetHandlerMessageTypes(results.Types);

            results.Types.AddRange(list);

            results.RemoveDuplicates();

            return(results);
        }
Exemple #5
0
        /// <summary>
        /// Traverses the specified base directory including all sub-directories, generating a list of assemblies that should be
        /// scanned for handlers, a list of skipped files, and a list of errors that occurred while scanning.
        /// </summary>
        public AssemblyScannerResults GetScannableAssemblies()
        {
            var results   = new AssemblyScannerResults();
            var processed = new Dictionary <string, bool>(StringComparer.OrdinalIgnoreCase);

            if (assemblyToScan != null)
            {
                if (ScanAssembly(assemblyToScan, processed))
                {
                    AddTypesToResult(assemblyToScan, results);
                }

                return(results);
            }

            if (ScanAppDomainAssemblies)
            {
                var appDomainAssemblies = AppDomain.CurrentDomain.GetAssemblies();

                foreach (var assembly in appDomainAssemblies)
                {
                    if (ScanAssembly(assembly, processed))
                    {
                        AddTypesToResult(assembly, results);
                    }
                }
            }

            var assemblies = new List <Assembly>();

            ScanAssembliesInDirectory(baseDirectoryToScan, assemblies, results);

            if (!string.IsNullOrWhiteSpace(AdditionalAssemblyScanningPath))
            {
                ScanAssembliesInDirectory(AdditionalAssemblyScanningPath, assemblies, results);
            }

            var platformAssembliesString = (string)AppDomain.CurrentDomain.GetData("TRUSTED_PLATFORM_ASSEMBLIES");

            if (!string.IsNullOrEmpty(platformAssembliesString))
            {
                var platformAssemblies = platformAssembliesString.Split(Path.PathSeparator);

                foreach (var platformAssembly in platformAssemblies)
                {
                    if (TryLoadScannableAssembly(platformAssembly, results, out var assembly))
                    {
                        assemblies.Add(assembly);
                    }
                }
            }

            foreach (var assembly in assemblies)
            {
                if (ScanAssembly(assembly, processed))
                {
                    AddTypesToResult(assembly, results);
                }
            }

            results.RemoveDuplicates();

            return(results);
        }
Exemple #6
0
        /// <summary>
        /// Traverses the specified base directory including all sub-directories, generating a list of assemblies that should be
        /// scanned for handlers, a list of skipped files, and a list of errors that occurred while scanning.
        /// </summary>
        public AssemblyScannerResults GetScannableAssemblies()
        {
            var results   = new AssemblyScannerResults();
            var processed = new Dictionary <string, bool>(StringComparer.OrdinalIgnoreCase);

            if (assemblyToScan != null)
            {
                if (ScanAssembly(assemblyToScan, processed))
                {
                    AddTypesToResult(assemblyToScan, results);
                }

                return(results);
            }

            if (ScanAppDomainAssemblies)
            {
                var appDomainAssemblies = AppDomain.CurrentDomain.GetAssemblies();

                foreach (var assembly in appDomainAssemblies)
                {
                    if (ScanAssembly(assembly, processed))
                    {
                        AddTypesToResult(assembly, results);
                    }
                }
            }

            var assemblies = new List <Assembly>();

            foreach (var assemblyFile in ScanDirectoryForAssemblyFiles(baseDirectoryToScan, ScanNestedDirectories))
            {
                if (TryLoadScannableAssembly(assemblyFile.FullName, results, out var assembly))
                {
                    assemblies.Add(assembly);
                }
            }

            var platformAssembliesString = (string)AppDomain.CurrentDomain.GetData("TRUSTED_PLATFORM_ASSEMBLIES");

            if (platformAssembliesString != null)
            {
                var platformAssemblies = platformAssembliesString.Split(Path.PathSeparator);

                foreach (var platformAssembly in platformAssemblies)
                {
                    if (TryLoadScannableAssembly(platformAssembly, results, out var assembly))
                    {
                        assemblies.Add(assembly);
                    }
                }
            }

            foreach (var assembly in assemblies)
            {
                if (ScanAssembly(assembly, processed))
                {
                    AddTypesToResult(assembly, results);
                }
            }

            results.RemoveDuplicates();

            return(results);
        }