Beispiel #1
0
 /// <summary>
 /// Create a PluginModule object.
 /// </summary>
 /// <param name="plugin">A reference to an actual plugin module instance.</param>
 /// <param name="pluginId">The ID of the plugin.</param>
 /// <param name="pluginName">The name of the plugin.</param>
 /// <param name="pluginVersion">The versionof the plugin.</param>
 /// <param name="pluginDescription">A description of the plugin.</param>
 public PluginModule(
     IQuickSharpPlugin plugin,
     string pluginId,
     string pluginName,
     int pluginVersion,
     string pluginDescription)
     : base(pluginId, pluginName, pluginVersion)
 {
     _plugin       = plugin;
     _description  = pluginDescription;
     _dependencies = new List <Plugin>();
 }
Beispiel #2
0
        GetPluginsFromAssembly(string pluginPath)
        {
            List <IQuickSharpPlugin> plugins =
                new List <IQuickSharpPlugin>();

            Assembly asm = null;

            try
            {
                asm = Assembly.LoadFile(pluginPath);
            }
            catch
            {
                // Ignore if not loadable.
            }

            if (asm != null)
            {
                try
                {
                    Type[] types = asm.GetTypes();

                    foreach (Type t in types)
                    {
                        /*
                         * QuickSharp.Core is not a plugin but will
                         * appear to be one as it contains the plugin
                         * interface type.
                         */

                        if (t == typeof(IQuickSharpPlugin))
                        {
                            continue;
                        }

                        /*
                         * Anything that implements the plugin interface
                         * is treated as a plugin.
                         */

                        if (typeof(IQuickSharpPlugin).IsAssignableFrom(t))
                        {
                            IQuickSharpPlugin plugin =
                                Activator.CreateInstance(t) as IQuickSharpPlugin;

                            if (plugin != null)
                            {
                                plugins.Add(plugin);
                            }
                        }
                    }
                }
                catch
                {
                    throw new Exception(String.Format(
                                            Resources.PluginDependencyError0,
                                            Path.GetFileName(pluginPath)));
                }
            }

            return(plugins);
        }