Пример #1
0
        private static void AddModuleAndDependenciesResursively(List <Type> moduleTypes, Type moduleType)
        {
            RocketModule.CheckRocketModuleType(moduleType);

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

            moduleTypes.Add(moduleType);

            foreach (var dependedModuleType in FindDependedModuleTypes(moduleType))
            {
                AddModuleAndDependenciesResursively(moduleTypes, dependedModuleType);
            }
        }
Пример #2
0
        public static List <Type> FindDependedModuleTypes(Type moduleType)
        {
            RocketModule.CheckRocketModuleType(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);
                }
            }

            return(dependencies);
        }