public async Task <IEnumerable <AssemblyModel> > GetAssembliesAsync() { var assemblyRegistry = new AssemblyReferenceCollection(); var reader = new AssemblyReader(assemblyRegistry); var files = _Sources .SelectMany(x => x.GetFiles("*.dll")) .OrderBy(x => x.Name) .Where(x => !IsExcluded(x)) .ToArray() .AsEnumerable(); var assemblyTasks = files .Select(x => reader.TryReadAsync(x)); var assemblies = (await Task.WhenAll(assemblyTasks)) .Where(x => x != null) .ToArray(); var knownAssemblies = assemblies.ToDictionary(x => x.Identity); foreach (var reference in assemblyRegistry) { knownAssemblies.TryGetValue(reference.Identity, out AssemblyModel knownAssembly); reference.KnownAssembly = knownAssembly; } return(assemblies); }
public AssemblyReader(AssemblyReferenceCollection register) { _Register = register ?? throw new ArgumentNullException(nameof(register), "must not be null"); }