public async Task <Plugin> AddPlugin(string name, string type, string author, string version, string[] requiredServices, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); List <ExternalServiceType> serviceTypes = null; string requiredServicesString = null; if (requiredServices != null && requiredServices.Length > 0) { requiredServicesString = string.Join(DataDelimiter.Comma.ToString(), requiredServices); var serviceTypeSpec = new ExternalServiceTypeFilterSpecification(requiredServices); serviceTypes = (await _externalServiceTypeRepository.GetBySpec(serviceTypeSpec, cancellationToken)).ToList(); var notSupportedServices = requiredServices.Where(s => !serviceTypes.Any(t => t.Name == s)).ToArray(); if (notSupportedServices.Length > 0) { throw new RequiredServicesNotSupportedException(notSupportedServices); } } var plugin = new Plugin { Name = name, Type = type, Author = author, Version = version, RequiredServicesString = requiredServicesString }; var id = await _pluginRepository.Create(plugin, cancellationToken); return(await _pluginRepository.GetById(id, cancellationToken)); }