예제 #1
0
        private IFieldDataPlugin LoadPlugin()
        {
            var pluginPath = Path.GetFullPath(Context.PluginPath);

            if (!File.Exists(pluginPath))
            {
                throw new ExpectedException($"Plugin file '{pluginPath}' does not exist.");
            }

            var plugins = new PluginLoader
            {
                Log     = Logger,
                Verbose = Context.Verbose
            }
            .LoadPlugins(new List <string> {
                pluginPath
            });

            if (!plugins.Any())
            {
                throw new ExpectedException($"No {nameof(IFieldDataPlugin)} plugin implementations found in '{pluginPath}'.");
            }

            if (plugins.Count > 1)
            {
                throw new ExpectedException($"{plugins.Count} {nameof(IFieldDataPlugin)} plugin implementations found in '{pluginPath}'.");
            }

            return(plugins.Single().Plugin);
        }