Esempio n. 1
0
 private void AddPlugin(object obj)
 {
     if (!string.IsNullOrEmpty(_pluginPath))
     {
         _pluginService.AddPlugin(_pluginPath);
     }
 }
        public async Task <IActionResult> RegisterProvider(NewProviderDto dto)
        {
            _logger.LogInformation("Registering provider. Request body: {@dto}", dto);

            try
            {
                var plugin = await _pluginService.AddPlugin(dto.Name, dto.Type, dto.Author, dto.Version, dto.RequiredServices);

                var result = _mapper.Map <ProviderDto>(plugin);

                if (dto.AdditionalConfigs != null && dto.AdditionalConfigs.Length > 0)
                {
                    var additionalConfigs = _mapper.Map <List <PluginAdditionalConfig> >(dto.AdditionalConfigs);
                    var _ = await _pluginAdditionalConfigService.AddAdditionalConfigs(plugin.Id, additionalConfigs);
                }

                return(CreatedAtRoute("GetProviderById", new { providerId = plugin.Id }, result));
            }
            catch (RequiredServicesNotSupportedException ex)
            {
                return(BadRequest(ex.Message));
            }
        }