public async Task <IReadOnlyList <PackageCarrier> > Load(PackagesLock packagesLock) { var mapper = new ModuleMapper(_framework, _modulesDirectory, Runtime.Windows, Environment.Is64BitProcess ? Architecture.x64 : Architecture.x86); var packageStack = mapper.BuildMap(packagesLock); var loadedPackages = new ConcurrentBag <PackageCarrier>(); while (packageStack.Any()) { var dependencyLayer = packageStack.Pop(); await TaskCombinators.ThrottledAsync(dependencyLayer, (context, token) => { return(Task.Run(() => { foreach (var module in LoadModule(context)) { loadedPackages.Add(module); } })); }, CancellationToken.None); } Packages = Packages.AddRange(loadedPackages); return(loadedPackages.ToList()); }
public async Task Load(IEnumerable <PackageIdentity> primaryPackages, PackagesLock packagesLock) { var mapper = new ModuleMapper(_project.Framework, _project.ModulesDirectory, _project.Runtime, _project.Architecture); var map = mapper.BuildMap(packagesLock); var dependencyPaths = new Dictionary <AssemblyName, AssemblyInfo>(new AssemblyNameComparer()); _dependencyAssemblies = dependencyPaths; while (map.TryPop(out var dependencyLayer)) { foreach (var context in dependencyLayer.Where(x => !x.IsMazeModule)) { foreach (var file in Directory.GetFiles(context.LibraryDirectory, "*.dll")) { dependencyPaths.Add(AssemblyName.GetAssemblyName(file), new AssemblyInfo(file)); } } await TaskCombinators.ThrottledAsync(dependencyLayer.Where(x => x.IsMazeModule), (context, token) => Task.Run(() => { foreach (var file in Directory.GetFiles(context.LibraryDirectory, "*.dll")) { var assembly = _assemblyLoadContext.LoadFromAssemblyPath(file); var typeDiscoveryService = new TypeDiscoveryService(assembly, context.Package); typeDiscoveryService.DiscoverTypes(ModuleTypeMap); } }), CancellationToken.None); } }