private List <Type> GetPluginTypes()
        {
            var types = PluginCollection?.SelectMany(p => p.PluginTypes).ToList();

            if (_DisconnectResolverOnPluginTypeLoad)
            {
                foreach (var plugin in PluginCollection)
                {
                    plugin.DependencyResolver.RemoveDependencyResolver();
                }
            }
            return(types);
        }
        public virtual IList <T> CreatePluginObjects(IPluginObjectCreator <T> pluginObjectCreator = null)
        {
            var pluginObjects = PluginCollection?.CreatePluginObjects(pluginObjectCreator ?? _PluginObjectCreator);

            if (_DisconnectResolverOnPluginLoad)
            {
                foreach (var plugin in PluginCollection)
                {
                    plugin.DependencyResolver.RemoveDependencyResolver();
                }
            }
            return(pluginObjects);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Loads any plugins found in the specified directories
        /// </summary>
        /// <param name="dirs"></param>
        public PluginCollection <T> LoadPlugins(IEnumerable <string> dirs)
        {
            var plugins   = new PluginCollection <T>();
            var fullPaths = new List <string>();

            foreach (var dir in dirs.Where(Directory.Exists))
            {
                var info = new DirectoryInfo(dir);
                if (fullPaths.Contains(info.FullName))
                {
                    continue;
                }
                fullPaths.Add(info.FullName);
                var allfiles     = Directory.GetFiles(info.FullName, AppPluginPaths.DefaultDllSearchString, SearchOption.AllDirectories);
                var foundplugins = LoadPlugins(allfiles.Where(s => !Path.GetDirectoryName(s).EndsWith(@"\bin")).ToArray());
                plugins.AddRange(foundplugins);
            }
            return(plugins);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Loads the plugins from files specificied.
        /// </summary>
        public PluginCollection <T> LoadPlugins(string[] pluginFiles)
        {
            var plugins = new PluginCollection <T>();

            foreach (var pluginFile in pluginFiles)
            {
                var plugin = LoadPlugin(pluginFile);
                if (plugin == null)
                {
                    continue;
                }
                if (plugin.PluginTypes?.Count == 0)
                {
                    continue;
                }
                plugins.Add(plugin);
            }
            return(plugins);
        }