Example #1
0
        public string Get()
        {
            var result = new StringBuilder();

            result.AppendLine("All:");
            foreach (var plugin in _plugins)
            {
                result.AppendLine($"{plugin.Name}: {plugin.Version}, Tags: {string.Join(", ", plugin.Tags)}");
            }

            var mathPlugins = _pluginProvider.GetByTag("MathOperator");
            var value1      = 10;
            var value2      = 20;

            result.AppendLine($"Math operations with values {value1} and {value2}");

            foreach (var mathPlugin in mathPlugins)
            {
                var mathPluginInstance = _serviceProvider.Create <IOperator>(mathPlugin);

                var mathResult = mathPluginInstance.Calculate(value1, value2);
                result.AppendLine($"{mathPlugin.Name}: {mathResult}");
            }

            return(result.ToString());
        }