Abc.Zebus.TinyHost.AssemblyScanner.GetAssembliesInFolder C# (CSharp) Method

GetAssembliesInFolder() private method

private GetAssembliesInFolder ( string path, string searchPattern, bool>.Func assemblyNameFilter = null ) : IEnumerable
path string
searchPattern string
assemblyNameFilter bool>.Func
return IEnumerable
        private static IEnumerable<Assembly> GetAssembliesInFolder(string path, string searchPattern, Func<string, bool> assemblyNameFilter = null)
        {
            var assemblies = new List<Assembly>();
            foreach (var filePath in System.IO.Directory.GetFiles(path, searchPattern))
            {
                try
                {
                    var fileName = Path.GetFileName(filePath);
                    if (assemblyNameFilter != null && !assemblyNameFilter(fileName))
                    {
                        _logger.Info($"Skipping : {fileName}");
                        continue;
                    }

                    _logger.Info($"Loading : {fileName}");
                    assemblies.Add(Assembly.LoadFrom(filePath));
                }
                catch (ReflectionTypeLoadException ex)
                {
                    foreach (var loaderException in ex.LoaderExceptions)
                        _logger.Warn($"Problem with loading {filePath}", loaderException);
                }
                catch (BadImageFormatException)
                {
                    _logger.Warn($"The assembly is not in the correct format (x86/x64/AnyCpu) {filePath}");
                }
                catch (FileNotFoundException ex)
                {
                    _logger.Warn($"Unable to load {ex.FileName}");
                }
                catch (FileLoadException ex)
                {
                    _logger.Warn($"Unable to load managed assembly {filePath}: {ex.Message}");
                }
            }
            return assemblies;
        }
    }

Same methods

AssemblyScanner::GetAssembliesInFolder ( string path, bool>.Func assemblyNameFilter = null ) : IEnumerable