예제 #1
0
        private List <IModuleDescriptor> GetDescriptors(
            IServiceCollection services,
            Type startupModuleType,
            PlugInSourceList plugInSources)
        {
            var modules = new List <ModuleDescriptor>();

            //All modules starting from the startup module
            foreach (var moduleType in ModuleHelper.FindAllModuleTypes(startupModuleType))
            {
                modules.Add(CreateModuleDescriptor(services, moduleType));
            }

            //Plugin modules
            foreach (var moduleType in plugInSources.GetAllModules())
            {
                if (modules.Any(m => m.Type == moduleType))
                {
                    continue;
                }

                modules.Add(CreateModuleDescriptor(services, moduleType));
            }

            ModuleHelper.SetDependencies(modules);

            return(modules.Cast <IModuleDescriptor>().ToList());
        }
예제 #2
0
 protected Type[] GetAllModules(PlugInSourceList plugInSources)
 {
     return(plugInSources
            .SelectMany(pluginSource => GetModulesWithAllDependencies(pluginSource))
            .Distinct()
            .ToArray());
 }
 public static void AddTypes(this PlugInSourceList list, params Type[] moduleTypes)
 {
     list.Add(new TypePlugInSource(moduleTypes));
 }
예제 #4
0
        protected List <IModuleDescriptor> LoadModules(IServiceCollection services, Type startupModuleType, PlugInSourceList plugInSources)
        {
            var modules = GetDescriptors(services, startupModuleType, plugInSources);

            modules = ModuleHelper.SortByDependency(modules, startupModuleType);

            return(modules);
        }