Exemplo n.º 1
0
        public Task Initialize()
        {
            var namingOptions  = _options.PluginNameOptions;
            var version        = namingOptions.PluginVersionGenerator(namingOptions, _pluginType);
            var pluginName     = namingOptions.PluginNameGenerator(namingOptions, _pluginType);
            var description    = namingOptions.PluginDescriptionGenerator(namingOptions, _pluginType);
            var productVersion = namingOptions.PluginProductVersionGenerator(namingOptions, _pluginType);

            var tags   = new List <string>();
            var finder = new TypeFinder();

            foreach (var typeFinderCriteria in _options.TypeFinderOptions.TypeFinderCriterias)
            {
                var isMatch = finder.IsMatch(typeFinderCriteria, _pluginType, _options.TypeFindingContext);

                if (isMatch)
                {
                    if (typeFinderCriteria.Tags?.Any() == true)
                    {
                        tags.AddRange(typeFinderCriteria.Tags);
                    }
                }
            }

            _plugin       = new PluginModel(_pluginType.Assembly, _pluginType, pluginName, version, this, description, productVersion, string.Empty, tags);
            IsInitialized = true;
            return(Task.CompletedTask);
        }