Exemple #1
0
        private static void AddModuleAndDependenciesResursively(List <Type> moduleTypes, Type moduleType)
        {
            ScorpioModule.CheckModuleType(moduleType);

            if (moduleTypes.Contains(moduleType))
            {
                return;
            }

            moduleTypes.Add(moduleType);

            foreach (var dependedModuleType in FindDependedModuleTypes(moduleType))
            {
                AddModuleAndDependenciesResursively(moduleTypes, dependedModuleType);
            }
        }
Exemple #2
0
        public static List <Type> FindDependedModuleTypes(Type moduleType)
        {
            ScorpioModule.CheckModuleType(moduleType);

            var dependencies = new List <Type>();

            var dependencyDescriptors = moduleType.GetCustomAttributes().OfType <IDependedTypesProvider>();

            foreach (var descriptor in dependencyDescriptors)
            {
                foreach (var dependedModuleType in descriptor.GetDependedTypes())
                {
                    dependencies.AddIfNotContains(dependedModuleType);
                }
            }
            if (dependencies.Count == 0 && moduleType != typeof(KernelModule))
            {
                dependencies.Add(typeof(KernelModule));
            }
            return(dependencies);
        }