private bool IsDetectedPlatform( DetectorContext ctx, IPlatformDetector platformDetector, out Tuple <PlatformName, string> platformResult) { platformResult = null; PlatformName platformName = platformDetector.DetectorPlatformName; PlatformDetectorResult detectionResult = platformDetector.Detect(ctx); if (detectionResult == null) { _logger.LogInformation($"Platform '{platformName}' was not detected in the given repository."); return(false); } if (string.IsNullOrEmpty(detectionResult.PlatformVersion)) { _logger.LogInformation($"Platform '{platformName}' was detected in the given repository, but " + $"no versions were detected."); platformResult = Tuple.Create(platformName, "Not Detected"); return(true); } string detectedVersion = detectionResult.PlatformVersion; platformResult = Tuple.Create(platformName, detectedVersion); _logger.LogInformation($"platform '{platformName}' was detected with version '{detectedVersion}'."); return(true); }
public IDictionary <PlatformName, string> GetAllDetectedPlatforms(DetectorContext ctx) { var detectedPlatforms = new Dictionary <PlatformName, string>(); foreach (var platformDetector in _platformDetectors) { PlatformName platformName = platformDetector.DetectorPlatformName; _logger.LogDebug($"Detecting '{platformName}' platform ..."); if (IsDetectedPlatform(ctx, platformDetector, out Tuple <PlatformName, string> platformResult)) { detectedPlatforms.Add(platformResult.Item1, platformResult.Item2); } } return(detectedPlatforms); }
/// <inheritdoc /> public IEnumerable <PlatformDetectorResult> GetAllDetectedPlatforms(DetectorContext context) { var detectedPlatforms = new List <PlatformDetectorResult>(); foreach (var platformDetector in _platformDetectors) { _logger.LogDebug($"Detecting platform using '{platformDetector.GetType()}'..."); if (IsDetectedPlatform( context, platformDetector, out PlatformDetectorResult platformResult)) { detectedPlatforms.Add(platformResult); } } return(detectedPlatforms); }
private bool IsDetectedPlatform( DetectorContext context, IPlatformDetector platformDetector, out PlatformDetectorResult platformResult) { platformResult = platformDetector.Detect(context); if (platformResult == null) { _logger.LogInformation("Could not detect any platform in the given repository."); return(false); } if (string.IsNullOrEmpty(platformResult.PlatformVersion)) { _logger.LogInformation( $"Platform '{platformResult.Platform}' was detected in the given repository, " + $"but no versions were detected."); } _logger.LogInformation( $"Platform '{platformResult.Platform}' was detected with version '{platformResult.PlatformVersion}'."); return(true); }