Пример #1
0
        public async Task <ServiceResponse <IReadOnlyDictionary <string, FoundPluginDto> > > Handle(PluginFinderQuery request, CancellationToken cancellationToken)
        {
            _logger.Warning($"[{nameof(PluginFinderHandler)}] Find (new = {request.OnlyNew}) available plugins");
            var home = await _unitOfWork.HomeRepository.GetFirstAsync().ConfigureAwait(false);

            var setting      = home.Settings.FirstOrDefault(c => c.IsActive || c.PluginPath.Contains("_private"));
            var foundPlugins = _pluginFinder.FindPluginsInAssemblies(setting.PluginPath);

            if (!request.OnlyNew)
            {
                return(foundPlugins.IsNullOrEmpty()
                    ? new ServiceResponse <IReadOnlyDictionary <string, FoundPluginDto> >(foundPlugins, true,
                                                                                          "Plugins available")
                    : new ServiceResponse <IReadOnlyDictionary <string, FoundPluginDto> >(foundPlugins, false,
                                                                                          "No plugins available"));
            }

            var filteredOrAllFoundPlugins = await _pluginFinder.FilterByPluginsInHome(foundPlugins);

            return(filteredOrAllFoundPlugins.IsNullOrEmpty()
                ? new ServiceResponse <IReadOnlyDictionary <string, FoundPluginDto> >(filteredOrAllFoundPlugins,
                                                                                      false,
                                                                                      "No new plugins available")
                : new ServiceResponse <IReadOnlyDictionary <string, FoundPluginDto> >(foundPlugins,
                                                                                      true,
                                                                                      "New plugins available"));
        }
Пример #2
0
        private async Task StartLoadPlugins(Setting setting)
        {
            var foundPlugins = _pluginFinder.FindPluginsInAssemblies(setting.PluginPath);
            var filteredOrAllFoundPlugins = await _pluginFinder.FilterByPluginsInHome(foundPlugins);

            if (filteredOrAllFoundPlugins.IsNullOrEmpty())
            {
                _logger.Warning($"[{nameof(AppStartup)}] No new Plugins loaded");
                return;
            }
            await _pluginHostService.Plugins.LoadAndAddToHomeAsync(new List <string> {
                setting.PluginPath
            }, LoadStrategyEnum.Multiple);
        }
Пример #3
0
        public async Task <ServiceResponse <string> > Handle(PluginLoadCommand request, CancellationToken cancellationToken)
        {
            var home = await _unitOfWork.HomeRepository.GetFirstAsync().ConfigureAwait(false);

            var setting = home.Settings.FirstOrDefault(c => c.IsActive || c.PluginPath.Contains("_private"));

            var foundPlugins = _pluginFinderService.FindPluginsInAssemblies(setting.PluginPath);
            var filteredOrAllFoundPlugins = await _pluginFinderService.FilterByPluginsInHome(foundPlugins);

            if (filteredOrAllFoundPlugins.IsNullOrEmpty())
            {
                _logger.Warning($"[{nameof(PluginLoadHandler)}] No new plugins available");
                return(new ServiceResponse <string>(null, false,
                                                    "No new plugins available"));
            }
            var path = request.Path.IsNullOrEmpty() ? setting.PluginPath : request.Path;

            var pluginsLoaded = await _pluginHostService.Plugins.LoadAndAddToHomeAsync(new [] { path }, request.LoadStrategyMultiple);

            return(new ServiceResponse <string>(pluginsLoaded ? "New Plugins loaded" : "Error loading new Plugins",
                                                pluginsLoaded));
        }