//////////////////////////////////////////////////// To Assembly Model ///////////////////////////////////////////////////// public static AssemblyModel ToAssemblyModel(this AssemblyExchange assemblyExchange, IList <AssemblyExchange> dependencies) { var referenceProvider = new Dictionary <string, ReferenceModel>(); var loadedAssemblies = dependencies.GroupBy(x => x.ShortName).Select(x => GetLoadedItem(x)).ToList(); var referenceCache = loadedAssemblies.Select(x => x.ToReferenceModelWithNewAssembly(referenceProvider)).ToDictionary(x => x.LoadedAssembly.Name); var notLoadedAssemblies = dependencies.Except(loadedAssemblies).Select(x => x.ToReferenceModelWithSearchAssembly(referenceCache)); foreach (var(_, value) in referenceCache) { referenceProvider.Add(value.AssemblyFullName, value); } foreach (var item in notLoadedAssemblies) { referenceProvider.Add(item.AssemblyFullName, item); } var assembly = assemblyExchange.ToAssemblyModel(referenceProvider); assembly.ConsolidateMissingAssemblies(referenceProvider, referenceCache); assembly.ConsolidateParentLink(referenceProvider); return(assembly); }
private static ReferenceModel ToReferenceModelWithNewAssembly(this AssemblyExchange assemblyExchange, IReadOnlyDictionary <string, ReferenceModel> referenceProvider) => ToReferenceModelWithAssembly(assemblyExchange, assemblyExchange.ToAssemblyModel(referenceProvider));