public static Result<IReadOnlyList<string>> Read(SourcePackageFile file)
 {
     if (!SourcePackagesFileReaders.ContainsKey(file.OriginalFileName))
     {
         Log.Warning("The filename {filename} was not recognised as a supported file format", file.OriginalFileName);
         return Result.Failed<IReadOnlyList<string>>($"The filename {file.OriginalFileName} was not recognised as a supported file format. Supported types are {SupportedFiles.CommaSeperate()}.");
     }
     return SourcePackagesFileReaders[file.OriginalFileName]
         .ReadDependencies(file.Contents)
         .AsSuccess();
 }
Esempio n. 2
0
 public static Result <IReadOnlyList <string> > Read(SourcePackageFile file)
 {
     if (!SourcePackagesFileReaders.ContainsKey(file.OriginalFileName))
     {
         Log.Warning("The filename {filename} was not recognised as a supported file format", file.OriginalFileName);
         return(Result.Failed <IReadOnlyList <string> >($"The filename {file.OriginalFileName} was not recognised as a supported file format. Supported types are {SupportedFiles.CommaSeperate()}."));
     }
     return(SourcePackagesFileReaders[file.OriginalFileName]
            .ReadDependencies(file.Contents)
            .AsSuccess());
 }
Esempio n. 3
0
        public static Result <IReadOnlyList <string> > Read(SourcePackageFile file)
        {
            if (!SourcePackagesFileReaders.ContainsKey(file.OriginalFileName) &&
                !SourcePackagesFileReaders.ContainsKey(file.OriginalFileExtension))
            {
                Log.Warning("The filename {filename} was not recognised as a supported file format",
                            file.OriginalFileName);
                return(Result.Failed <IReadOnlyList <string> >(
                           $"The filename {file.OriginalFileName} was not recognised as a supported file format. Supported types are {SupportedFiles.CommaSeperate()}."));
            }

            var sourcePackageFileReader = SourcePackagesFileReaders.FirstOrDefault(r => r.Key.Equals(file.OriginalFileName) || r.Key.Equals(file.OriginalFileExtension)).Value;

            return(sourcePackageFileReader
                   .ReadDependencies(file.Contents)
                   .AsSuccess());
        }
        private async Task<PackageResult> Process(SourcePackageFile file)
        {
            try
            {
                var dependencies = SourcePackageFileReader.Read(file);
                if (dependencies.WasFailure)
                    return PackageResult.Failed(file.Name, dependencies.ErrorString);

                var dependencyResults = await GetDependencyResults(dependencies.Value);
                return PackageResult.InvestigationTarget(file.Name, dependencyResults);
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Error processing supplied data file");
                return PackageResult.Failed(file.Name, "An error occured - " + ex.Message);
            }
        }