Пример #1
0
        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();
        }
Пример #2
0
        public override bool Equals(object obj)
        {
            AssemblyScanSettings other = obj as AssemblyScanSettings;

            if (other == null)
            {
                return(false);
            }

            return(other.Assembly.FullName == Assembly.FullName && other.Namespace == Namespace);
        }
Пример #3
0
		public override bool Equals(object obj)
		{
			AssemblyScanSettings other = obj as AssemblyScanSettings;
			if (other == null)
				return false;

			return
				other.Assembly.FullName == Assembly.FullName
				&& other.Namespace != null
				&& other.Namespace.Equals(Namespace, StringComparison.InvariantCultureIgnoreCase);
		}
Пример #4
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()))
                                                   .Distinct();
            IEnumerable <Type>     allNonAbstractCandidateTypes = allCandidateTypes.Where(t => !t.IsAbstract);
            IEnumerable <Assembly> allCandidateAssemblies       = assembliesToScan.Select(x => x.Assembly)
                                                                  .Union(scanIncludeList.Select(x => x.Assembly))
                                                                  .Distinct();

            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);
        }
Пример #5
0
        internal static void Scan(
            this IServiceCollection serviceCollection,
            Options options,
            IEnumerable <AssemblyScanSettings> assembliesToScan,
            IEnumerable <AssemblyScanSettings> scanIncludeList)
        {
            if (assembliesToScan == null || assembliesToScan.Count() == 0)
            {
                throw new ArgumentNullException(nameof(assembliesToScan));
            }

            GetCandidateTypes(
                assembliesToScan: assembliesToScan,
                scanIncludeList: scanIncludeList ?? new List <AssemblyScanSettings>(),
                allCandidateTypes: out Type[] allCandidateTypes,
                allNonAbstractCandidateTypes: out Type[] allNonAbstractCandidateTypes);

            // Classes must not be abstract
            DiscoveredReducerClass[] discoveredReducerClasses =
                ReducerClassessDiscovery.DiscoverReducerClasses(serviceCollection, allNonAbstractCandidateTypes);

            DiscoveredEffectClass[] discoveredEffectClasses =
                EffectClassessDiscovery.DiscoverEffectClasses(serviceCollection, allNonAbstractCandidateTypes);

            // Method reducer/effects may belong to abstract classes
            TypeAndMethodInfo[] allCandidateMethods = AssemblyScanSettings.FilterMethods(allCandidateTypes);

            DiscoveredReducerMethod[] discoveredReducerMethods =
                ReducerMethodsDiscovery.DiscoverReducerMethods(serviceCollection, allCandidateMethods);

            DiscoveredEffectMethod[] discoveredEffectMethods =
                EffectMethodsDiscovery.DiscoverEffectMethods(serviceCollection, allCandidateMethods);

            DiscoveredFeatureClass[] discoveredFeatureClasses =
                FeatureClassesDiscovery.DiscoverFeatureClasses(
                    serviceCollection: serviceCollection,
                    allCandidateTypes: allNonAbstractCandidateTypes,
                    discoveredReducerClasses: discoveredReducerClasses,
                    discoveredReducerMethods: discoveredReducerMethods);

            RegisterStore(
                serviceCollection: serviceCollection,
                options: options,
                discoveredFeatureClasses: discoveredFeatureClasses,
                discoveredEffectClasses: discoveredEffectClasses,
                discoveredEffectMethods: discoveredEffectMethods);
        }