public void PopulateSymbioteList() { var dependencies = ImplementorsOfType.TryGet(typeof(IDefineDependencies)); var scanners = ImplementorsOfType.TryGet(typeof(IProvideScan)); var initializers = ImplementorsOfType.TryGet(typeof(IInitialize)); DependencyDefinitions = dependencies.Item1 ? dependencies.Item2.Where(x => x.IsConcrete()).ToList() : new List <Type>(); ScanningInstructions = scanners.Item1 ? scanners.Item2.Where(x => x.IsConcrete()).ToList() : new List <Type>(); SymbioteInitializers = initializers.Item1 ? initializers.Item2.Where(x => x.IsConcrete()).ToList() : new List <Type>(); var containingAssemblies = DependencyDefinitions.Select(x => x.Assembly) .Concat(ScanningInstructions.Select(x => x.Assembly)) .Distinct(); ConfiguredSymbiotes = containingAssemblies.ToDictionary(x => x, x => false); }
public void LoadTypeList(Assembly assembly) { var types = assembly.GetTypes().ToList(); AssemblyTypes[assembly] = types; types.ForEach(t => { TypeAssemblies[t] = assembly; var parents = Reflector.GetInheritanceChain(t).ToList(); TypeHierarchies[t] = parents; parents.ForEach(p => { var parent = p.IsGenericType ? p.GetGenericTypeDefinition() : p; ImplementorsOfType .AddOrUpdate(parent, c => { var l = new List <Type>(1000); l.Add(t); return(l); }, (c, l) => { l.Add(t); return(l); }); var closes = parent.IsOpenGeneric() && t.Closes(parent); if (closes) { Closers.AddOrUpdate(parent, c => { var l = new List <Type>(1000); l.Add(t); return(l); }, (c, l) => { l.Add(t); return(l); }); } }); }); var concreteTypesWithSingleImplementors = ImplementorsOfType .Where(x => !x.Key.IsConcrete() && x.Value.Count == 1).ToList(); var assignable = concreteTypesWithSingleImplementors .Where(x => x.Value.First().IsConcreteAndAssignableTo(x.Key)).ToList(); assignable.ForEach(x => SingleImplementations[x.Key] = x.Value.First()); }