private async Task <IEnumerable <string> > LoadScriptsAsync(
            SourceFileParametrization fileParametrization,
            CancellationToken ct)
        {
            if (fileParametrization.FilePath != null)
            {
                var script = await _fileGateway.GetFileContentAsync(
                    fileParametrization.FilePath,
                    ct);

                return(new[] { script });
            }
            else if (fileParametrization.FolderPath != null)
            {
                var scripts = _fileGateway
                              .ChangeFolder(fileParametrization.FolderPath)
                              .GetFolderContentsAsync(fileParametrization.Extensions, ct);
                var contents = (await scripts.ToEnumerableAsync())
                               .Select(t => t.content);

                return(contents);
            }
            else
            {
                throw new InvalidOperationException("We should never get here");
            }
        }
Exemplo n.º 2
0
        internal async Task <MainParameterization> LoadParameterizationAsync(
            string parameterFilePath,
            IEnumerable <string> pathOverrides)
        {
            try
            {
                var deserializer = new DeserializerBuilder()
                                   .WithNamingConvention(CamelCaseNamingConvention.Instance)
                                   .Build();
                var parameterText = await _fileGateway.GetFileContentAsync(parameterFilePath);

                var parameters = deserializer.Deserialize <MainParameterization>(parameterText);

                if (parameters == null)
                {
                    throw new DeltaException($"File '{parameterFilePath}' doesn't contain valid parameters");
                }

                ParameterOverrideHelper.InplaceOverride(parameters, pathOverrides);

                parameters.Validate();

                return(parameters);
            }
            catch (JsonException ex)
            {
                throw new DeltaException(
                          $"Issue reading the parameter file '{parameterFilePath}'",
                          ex);
            }
        }