public bool ExecutePluginChain <T>(string usage, T argument, out IPluginChain <T> result) { if (!plugins.TryGetValue(usage, out ICollection <IPlugin> pluginList)) { result = null; return(false); } foreach (IPlugin plugin in pluginList) { if (!(plugin is IPluginChain <T> pluginChain)) { continue; } result = pluginChain; if (!pluginChain.Execute(argument)) { continue; } else { return(true); } } result = null; return(false); }
/// <summary> /// Executes chainable plugin entry points accepts 1 argument with specific <see cref="HookAttribute.usage"/> tag /// until it tells to stop propagation, and returns it. /// </summary> /// <typeparam name="T">Argument type</typeparam> /// <param name="usage">The usage tag defined in the loaded plugins</param> /// <param name="argument">The argument should be passed to the plugins</param> /// <param name="results">Collections that will be appended the executed entry points instances, can be <c>null</c>.</param> /// <returns><c>true</c> when successful, otherwise <c>false</c>.</returns> public bool ExecutePluginChain <T>(string usage, T argument, out IPluginChain <T> result) { if (usage == null) { throw new ArgumentNullException(nameof(usage)); } foreach (LoadedPlugin plugin in loadedPlugins.Values) { if (plugin.ExecutePluginChain(usage, argument, out result)) { return(true); } } result = null; return(false); }