Exemplo n.º 1
0
        internal static void Scan(this IServiceCollection serviceCollection,
                                  IEnumerable <AssemblyScanSettings> assembliesToScan, IEnumerable <AssemblyScanSettings> scanIncludeList)
        {
            if (assembliesToScan == null || !assembliesToScan.Any())
            {
                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();
            IEnumerable <Type>     allNonAbstractCandidateTypes = allCandidateTypes.Where(t => !t.IsAbstract);
            IEnumerable <Assembly> allCandidateAssemblies       = assembliesToScan.Select(x => x.Assembly)
                                                                  .Union(scanIncludeList.Select(x => x.Assembly))
                                                                  .Distinct()
                                                                  .ToList();

            IEnumerable <AssemblyScanSettings> scanExcludeList =
                MiddlewareClassesDiscovery.FindMiddlewareLocations(allCandidateAssemblies);

            allCandidateTypes = AssemblyScanSettings.Filter(
                types: allCandidateTypes,
                scanExcludeList: scanExcludeList,
                scanIncludeList: scanIncludeList);


            IEnumerable <DiscoveredReducerClass> discoveredReducerClasses =
                ReducerClassessDiscovery.DiscoverReducerClasses(serviceCollection, allNonAbstractCandidateTypes);

            IEnumerable <DiscoveredReducerMethod> discoveredReducerMethods =
                ReducerMethodsDiscovery.DiscoverReducerMethods(serviceCollection, allCandidateTypes);

            IEnumerable <DiscoveredEffectClass> discoveredEffectClasses =
                EffectClassessDiscovery.DiscoverEffectClasses(serviceCollection, allNonAbstractCandidateTypes);

            IEnumerable <DiscoveredEffectMethod> discoveredEffectMethods =
                EffectMethodsDiscovery.DiscoverEffectMethods(serviceCollection, allCandidateTypes);

            IEnumerable <DiscoveredFeatureClass> discoveredFeatureClasses =
                FeatureClassesDiscovery.DiscoverFeatureClasses(
                    serviceCollection,
                    allNonAbstractCandidateTypes,
                    discoveredReducerClasses,
                    discoveredReducerMethods);

            RegisterStore(
                serviceCollection,
                discoveredFeatureClasses,
                discoveredEffectClasses,
                discoveredEffectMethods);
        }
Exemplo n.º 2
0
        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()))
                                                   .Where(t => !t.IsAbstract)
                                                   .Distinct();
            IEnumerable <Assembly> allCandidateAssemblies = assembliesToScan.Select(x => x.Assembly)
                                                            .Union(scanIncludeList.Select(x => x.Assembly))
                                                            .Distinct();

            IEnumerable <AssemblyScanSettings> scanExcludeList =
                MiddlewareScanner.FindMiddlewareLocations(allCandidateAssemblies);

            allCandidateTypes = AssemblyScanSettings.Filter(
                types: allCandidateTypes,
                scanExcludeList: scanExcludeList,
                scanIncludeList: scanIncludeList);


            IEnumerable <DiscoveredReducerInfo> discoveredReducerInfos =
                ReducersRegistration.DiscoverReducers(serviceCollection, allCandidateTypes);

            IEnumerable <DiscoveredEffectInfo> discoveredEffectInfos =
                EffectsRegistration.DiscoverEffects(serviceCollection, allCandidateTypes);

            IEnumerable <DiscoveredFeatureInfo> discoveredFeatureInfos =
                FeaturesRegistration.DiscoverFeatures(serviceCollection, allCandidateTypes, discoveredReducerInfos);

            RegisterStore(serviceCollection, discoveredFeatureInfos, discoveredEffectInfos);
        }