Beispiel #1
0
        public void StartPlugin <T>(Dictionary <string, object> data = null)
        {
            IPlugin plugin = pluginFactory.GetPlugin(typeof(T), data);

            plugin.Start();

            plugins.Add(plugin);
        }
        public void AddNode(AddNodeRequest addNodeRequest)
        {
            var plugin = pluginFactory.GetPlugin(addNodeRequest.TypeId, nodeProgress);

            plugin.Location = addNodeRequest.Location;
            dataFlowFacade.AddNode(plugin);
            AddNodeToStatus(plugin);
            progress.Report(dataFlowStatus);
        }
        /// <summary>
        /// Loads the plugin.
        /// </summary>
        /// <param name="dllFile">The path to the DLL file.</param>
        /// <param name="xmlConfig">The NTestController.xml config path and filename.</param>
        /// <returns>The plugin.</returns>
        /// <exception cref="ArgumentNullException">A null or whitespace only argument was passed in.</exception>
        /// <exception cref="DllNotFoundException">The DLL doesn't exist.</exception>
        /// <exception cref="EntryPointNotFoundException">The DLL doesn't implement the IPlugin interface.</exception>
        public static IPlugin LoadPlugin(string dllFile, string xmlConfig)
        {
            ThrowIf.StringIsNullOrWhiteSpace(dllFile, nameof(dllFile));
            ThrowIf.StringIsNullOrWhiteSpace(xmlConfig, nameof(xmlConfig));

            if (!File.Exists(dllFile))
            {
                throw new DllNotFoundException(StringUtils.FormatInvariant("Could not find: '{0}'!", dllFile));
            }

            IPlugin plugin = null;

            AssemblyName an       = AssemblyName.GetAssemblyName(dllFile);
            Assembly     assembly = Assembly.Load(an);

            Type[] types = assembly.GetTypes();

            foreach (Type type in types)
            {
                if (type.IsInterface || type.IsAbstract)
                {
                    continue;
                }
                else
                {
                    if (type.GetInterface(typeof(IPluginFactory).FullName) != null)
                    {
                        IPluginFactory pluginFactory = (IPluginFactory)Activator.CreateInstance(type);
                        plugin = pluginFactory.GetPlugin(xmlConfig);
                    }
                }
            }

            if (plugin == null)
            {
                throw new EntryPointNotFoundException(StringUtils.FormatInvariant("No implementations of IPlugin were found in: '{0}'!", dllFile));
            }

            return(plugin);
        }
Beispiel #4
0
 /// <summary>
 /// Gets plugin by name
 /// </summary>
 /// <param name="pluginName">Plugin name</param>
 /// <returns>Instance of plugin</returns>
 /// <exception cref="System.InvalidOperationException">Thrown when plugin is missing</exception>
 public static IPlugin GetPlugin(string pluginName)
 {
     return(PluginFactory.GetPlugin(pluginName));
 }