/// <summary>
        /// Get plugin descriptors
        /// </summary>
        /// <param name="loadMode">Load plugins mode</param>
        /// <param name="group">Filter by plugin group; pass null to load all records</param>
        /// <returns>Plugin descriptors</returns>
        public virtual IEnumerable <PluginDescriptor> GetPluginDescriptors(PluginsType loadMode = PluginsType.InstalledOnly, string group = null)
        {
            //ensure plugins are loaded
            EnsurePluginsAreLoaded();

            return(_plugins.Where(p => CheckLoadMode(p, loadMode) && CheckGroup(p, group)));
        }
Beispiel #2
0
 public Plugins(string na, string des, MethodInfo p_mi, PluginsType p_pt)
 {
     name        = na;
     description = des;
     mi          = p_mi;
     pt          = p_pt;
 }
        /// <summary>
        /// Check whether the plugin is available
        /// </summary>
        /// <param name="pluginDescriptor">Plugin descriptor to check</param>
        /// <param name="loadMode">Load plugins mode</param>
        /// <returns>true - available; false - no</returns>
        protected virtual bool CheckLoadMode(PluginDescriptor pluginDescriptor, PluginsType loadMode)
        {
            if (pluginDescriptor == null)
            {
                throw new ArgumentNullException("pluginDescriptor");
            }

            switch (loadMode)
            {
            case PluginsType.All:
                //no filering
                return(true);

            case PluginsType.InstalledOnly:
                return(pluginDescriptor.Installed);

            case PluginsType.NotInstalledOnly:
                return(!pluginDescriptor.Installed);

            default:
                throw new Exception("Not supported LoadPluginsMode");
            }
        }
 /// <summary>
 /// Get a plugin descriptor by its system name
 /// </summary>
 /// <typeparam name="T">The type of plugin to get.</typeparam>
 /// <param name="systemName">Plugin system name</param>
 /// <param name="loadMode">Load plugins mode</param>
 /// <returns>>Plugin descriptor</returns>
 public virtual PluginDescriptor GetPluginDescriptorBySystemName <T>(string systemName, PluginsType loadMode = PluginsType.InstalledOnly)
     where T : class, IPlugin
 {
     return(GetPluginDescriptors <T>(loadMode)
            .SingleOrDefault(p => p.SystemName.Equals(systemName, StringComparison.InvariantCultureIgnoreCase)));
 }
 /// <summary>
 /// Get plugin descriptors
 /// </summary>
 /// <typeparam name="T">The type of plugin to get.</typeparam>
 /// <param name="loadMode">Load plugins mode</param>
 /// <param name="group">Filter by plugin group; pass null to load all records</param>
 /// <returns>Plugin descriptors</returns>
 public virtual IEnumerable <PluginDescriptor> GetPluginDescriptors <T>(PluginsType loadMode = PluginsType.InstalledOnly, string group = null)
     where T : class, IPlugin
 {
     return(GetPluginDescriptors(loadMode, group)
            .Where(p => typeof(T).IsAssignableFrom(p.PluginType)));
 }
 /// <summary>
 /// Gets plugins
 /// </summary>
 /// <typeparam name="T">The type of plugins to get.</typeparam>
 /// <param name="loadMode">Load plugins mode</param>
 /// <param name="group">Filter by plugin group; pass null to load all records</param>
 /// <returns>Plugins</returns>
 public virtual IEnumerable <T> GetPlugins <T>(PluginsType loadMode = PluginsType.InstalledOnly, string group = null) where T : class, IPlugin
 {
     return(GetPluginDescriptors <T>(loadMode, group).Select(p => p.Instance <T>()));
 }