Пример #1
0
        private void FillModules(Assembly assembly, List <Assembly> scannedAssemblies)
        {
            if (scannedAssemblies.Contains(assembly))
            {
                return;
            }

            scannedAssemblies.Add(assembly);

            foreach (var type in assembly.GetTypes())
            {
                //Skip types those are not Abp Module
                if (!AbpModuleHelper.IsAbpModule(type))
                {
                    continue;
                }

                //Prevent multiple adding same module
                var moduleInfo = _modules.FirstOrDefault(m => m.Type == type);
                if (moduleInfo == null)
                {
                    moduleInfo = AbpModuleInfo.CreateForType(type);
                    _modules.Add(moduleInfo);
                }

                //Check for depended modules
                var dependedModuleTypes = moduleInfo.Instance.GetDependedModules();
                foreach (var dependedModuleType in dependedModuleTypes)
                {
                    FillModules(dependedModuleType.Assembly, scannedAssemblies);
                }

                Logger.Debug("Loaded module: " + moduleInfo);
            }
        }
Пример #2
0
        public static AbpModuleInfo CreateForType(Type type)
        {
            if (!AbpModuleHelper.IsAbpModule(type))
            {
                throw new AbpException(
                          string.Format(
                              "type {0} is not an Abp module. An Abp module must be subclass of AbpModule, must declare AbpModuleAttribute attribute and must not be abstract!",
                              type.FullName));
            }

            return(new AbpModuleInfo((AbpModule)Activator.CreateInstance(type, new object[] { })));
        }