示例#1
0
        private List <IPlugin> LoadModulesFromList(String pattern)
        {
            //Get all plugins with given name regexp
            log.Info("Initializing Finder");
            List <FileInfo> files = _finder.FindFiles(pattern);

            log.Info("Got " + files.Count + " files");
            //Iterate over results and load each file into separate container
            //Then store the container into a plugin list
            log.Info("Trying to load each file :");
            foreach (FileInfo file in files)
            {
                log.Info("Attempting to load file " + file.FullName);
                IPluginContainer pc = new PluginContainer();
                pc.LoadPlugin(file.FullName);
                if (pc.Modules.Count > 0)
                {
                    log.Info("Loading the plugin in the file " + file.FullName + " has succeeded");
                    pc.Modules.ForEach(p => _plugins[p] = pc);
                    _pluginContainers.Add(pc);
                }
                else
                {
                    log.Info("Failed to load the plugin in the file " + file.FullName);
                }
            }

            log.Info("Successfully loaded " + _plugins.Count + " files");

            //Return a list of all modules loaded
            return(_plugins.Keys.ToList());
        }