コード例 #1
0
        public IPackageExtractor GetExtractor(string packageFile)
        {
            var extension = Path.GetExtension(packageFile);

            if (string.IsNullOrEmpty(extension))
            {
                throw new FileFormatException("Package is missing file extension. This is needed to select the correct extraction algorithm.");
            }

            var file = PackageName.FromFile(packageFile);

            if (!Extensions.Contains(file.Extension))
            {
                throw new FileFormatException($"Unsupported file extension `{extension}`");
            }

            var extractor = FindByExtension(file);

            if (extractor != null)
            {
                return(extractor);
            }

            throw new FileFormatException(supportLinkGenerator.GenerateSupportMessage(
                                              $"This step supports packages with the following extensions: {Extractors.SelectMany(e => e.Extensions).Distinct().Aggregate((result, e) => result + ", " + e)}.\n" +
                                              $"The supplied package has the extension \"{file.Extension}\" which is not supported.",
                                              "JAVA-DEPLOY-ERROR-0001"));
        }
コード例 #2
0
        public IPackageExtractor GetExtractor(string packageFile)
        {
            var extension = Path.GetExtension(packageFile);

            if (string.IsNullOrEmpty(extension))
            {
                throw new CommandException("Package is missing file extension. This is needed to select the correct extraction algorithm.");
            }

            var file      = PackageName.FromFile(packageFile);
            var extractor = extractors.FirstOrDefault(p => p.Extensions.Any(ext => file.Extension.Equals(ext, StringComparison.OrdinalIgnoreCase)));

            if (extractor == null)
            {
                throw new CommandException($"Unsupported file extension `{extension}`");
            }

            return(extractor);
        }
コード例 #3
0
 public static PackagePhysicalFileMetadata Build(string fullFilePath)
 {
     return(Build(fullFilePath, PackageName.FromFile(fullFilePath)));
 }