public async Task <string> Get() { var scriptPlugin = _pluginCatalog.GetPlugins().First(); dynamic scriptInstance = Activator.CreateInstance(scriptPlugin); var scriptResult = await scriptInstance.Run(); var typePlugin = _pluginCatalog.Get("MyPlugin", Version.Parse("1.5.0.0")); dynamic typeInstance = typePlugin.Create(_sp); var typeResult = typeInstance.RunThings(); var result = new StringBuilder(); result.AppendLine(scriptResult); result.AppendLine(typeResult); return(result.ToString()); }
/// <summary> /// Gets the plugins by tag. /// </summary> /// <param name="catalog">The catalog from which the plugin is retrieved.</param> /// <param name="tag">The tag.</param> /// <returns>The plugin</returns> public static List <Plugin> GetByTag(this IPluginCatalog catalog, string tag) { return(catalog.GetPlugins().Where(x => x.Tags.Contains(tag)).ToList()); }
/// <summary> /// Gets the only plugin inside the catalog. Throws if there is none or multiple. /// </summary> /// <param name="catalog">The catalog from which the plugin is retrieved.</param> /// <returns>The plugin</returns> public static Plugin Single(this IPluginCatalog catalog) { var plugins = catalog.GetPlugins(); return(plugins.Single()); }