private static void GetCandidateTypes( IEnumerable <AssemblyScanSettings> assembliesToScan, IEnumerable <AssemblyScanSettings> scanIncludeList, out Type[] allCandidateTypes, out Type[] allNonAbstractCandidateTypes) { Assembly[] allCandidateAssemblies = assembliesToScan .Select(x => x.Assembly) .Union(scanIncludeList.Select(x => x.Assembly)) .Distinct() .ToArray(); AssemblyScanSettings[] scanExcludeList = MiddlewareClassesDiscovery.FindMiddlewareLocations(allCandidateAssemblies); allCandidateTypes = AssemblyScanSettings.FilterClasses( scanExcludeList: scanExcludeList, scanIncludeList: scanIncludeList, types: allCandidateAssemblies .SelectMany(x => x.GetTypes()) .Union(scanIncludeList.SelectMany(x => x.Assembly.GetTypes())) .Where(t => !t.IsGenericType) .Distinct() .ToArray()); allNonAbstractCandidateTypes = allCandidateTypes .Where(t => !t.IsAbstract) .ToArray(); }
internal static void Scan( this IServiceCollection serviceCollection, IEnumerable <AssemblyScanSettings> assembliesToScan, IEnumerable <AssemblyScanSettings> scanIncludeList) { if (assembliesToScan == null || assembliesToScan.Count() == 0) { throw new ArgumentNullException(nameof(assembliesToScan)); } scanIncludeList = scanIncludeList ?? new List <AssemblyScanSettings>(); IEnumerable <Type> allCandidateTypes = assembliesToScan .SelectMany(x => x.Assembly.GetTypes()) .Union(scanIncludeList.SelectMany(x => x.Assembly.GetTypes())) .Distinct() .ToArray(); IEnumerable <Type> allNonAbstractCandidateTypes = allCandidateTypes .Where(t => !t.IsAbstract) .ToArray(); IEnumerable <Assembly> allCandidateAssemblies = assembliesToScan .Select(x => x.Assembly) .Union(scanIncludeList.Select(x => x.Assembly)) .Distinct() .ToArray(); IEnumerable <AssemblyScanSettings> scanExcludeList = MiddlewareClassesDiscovery.FindMiddlewareLocations(allCandidateAssemblies); allCandidateTypes = AssemblyScanSettings.FilterClasses( types: allCandidateTypes, scanExcludeList: scanExcludeList, scanIncludeList: scanIncludeList); IEnumerable <MethodInfo> allCandidateMethods = AssemblyScanSettings.FilterMethods(allCandidateTypes); IEnumerable <DiscoveredReducerClass> discoveredReducerClasses = ReducerClassessDiscovery.DiscoverReducerClasses(serviceCollection, allNonAbstractCandidateTypes); IEnumerable <DiscoveredReducerMethod> discoveredReducerMethods = ReducerMethodsDiscovery.DiscoverReducerMethods(serviceCollection, allCandidateMethods); IEnumerable <DiscoveredEffectClass> discoveredEffectClasses = EffectClassessDiscovery.DiscoverEffectClasses(serviceCollection, allNonAbstractCandidateTypes); IEnumerable <DiscoveredEffectMethod> discoveredEffectMethods = EffectMethodsDiscovery.DiscoverEffectMethods(serviceCollection, allCandidateMethods); IEnumerable <DiscoveredFeatureClass> discoveredFeatureClasses = FeatureClassesDiscovery.DiscoverFeatureClasses( serviceCollection, allNonAbstractCandidateTypes, discoveredReducerClasses, discoveredReducerMethods); RegisterStore( serviceCollection, discoveredFeatureClasses, discoveredEffectClasses, discoveredEffectMethods); }