Example #1
0
 private static void AddModuleAndDependenciesResursively(List <Type> moduleTypes, Type moduleType)
 {
     LmsModule.CheckLmsModuleType(moduleType);
     if (moduleTypes.Contains(moduleType))
     {
         return;
     }
     moduleTypes.Add(moduleType);
     foreach (var dependedModuleType in FindDependedModuleTypes(moduleType))
     {
         AddModuleAndDependenciesResursively(moduleTypes, dependedModuleType);
     }
 }
Example #2
0
        public static List <Type> FindDependedModuleTypes(Type moduleType)
        {
            LmsModule.CheckLmsModuleType(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);
        }