private List <ExtensionDescriptor> AvailableExtensionsInFolder(string path, string extensionType, string manifestName, bool manifestIsOptional) { var localList = new List <ExtensionDescriptor>(); if (string.IsNullOrEmpty(path)) { return(localList); } if (_logger.IsEnabled(LogLevel.Information)) { _logger.LogInformation("Start looking for extensions in '{0}'...", path); } var subfolders = _fileSystem.ListDirectories(path); foreach (var subfolder in subfolders) { var extensionId = subfolder.Name; var manifestPath = _fileSystem.Combine(path, extensionId, manifestName); try { var descriptor = GetExtensionDescriptor(path, extensionId, extensionType, manifestPath, manifestIsOptional); if (descriptor == null) { continue; } if (descriptor.Path != null && !descriptor.Path.IsValidUrlSegment()) { _logger.LogError("The module '{0}' could not be loaded because it has an invalid Path ({1}). It was ignored. The Path if specified must be a valid URL segment. The best bet is to stick with letters and numbers with no spaces.", extensionId, descriptor.Path); continue; } if (descriptor.Path == null) { descriptor.Path = descriptor.Name.IsValidUrlSegment() ? descriptor.Name : descriptor.Id; } localList.Add(descriptor); } catch (Exception ex) { // Ignore invalid module manifests _logger.LogError(string.Format("The module '{0}' could not be loaded. It was ignored.", extensionId), ex); } } if (_logger.IsEnabled(LogLevel.Information)) { _logger.LogInformation("Done looking for extensions in '{0}': {1}", path, string.Join(", ", localList.Select(d => d.Id))); } return(localList); }
public IEnumerable <DirectoryInfo> ListDirectories(string path) { return(_fileSystem.ListDirectories(path)); }