Exemple #1
0
        /// <summary>
        /// Loads a plugin from selected path asynchronously.
        /// </summary>
        /// <param name="path">Path to load the plugin from. Can point either to local <b>DLL</b>, <b>C# code file</b> or a <b>GitHub project url</b>.</param>
        /// <param name="permissions">Permissions granted to the plugin.</param>
        /// <returns>Loaded plugin. If loading failed, <see cref="PluginContainer.Plugin"/> property will be null.</returns>
        public async Task <PluginContainer> LoadPluginAsync(string path, PluginPermissions permissions)
        {
            IPluginProvider provider = PluginProviderSelector.GetPluginProvider(path);

            if (provider == null)
            {
                logger?.LogError($"Couldn't load plugin from path '{path}'");
                return(null);
            }

            PluginContainer plugin = await provider.GetPluginAsync(path, logger).ConfigureAwait(false);

            return(HandlePlugin(plugin, permissions));
        }