Exemplo n.º 1
0
        public bool AssertFilesExist(ILogger log)
        {
            var allExists = TransformFile.Exists();

            if (allExists == false)
            {
                log.Error($"{nameof(TransformFile)} not found: {TransformFile.FullName().Highlight()}");
            }
            allExists = allExists && ConfigFile.Exists();
            if (allExists == false)
            {
                log.Error($"{nameof(ConfigFile)} not found: {ConfigFile.FullName().Highlight()}");
            }
            allExists = allExists && ConfigTransform != null;//should never fail here. Then it's a code error and not application error

            return(allExists);
        }
Exemplo n.º 2
0
        public TransformResult Transform()
        {
            var result = new TransformResult
            {
                TransformFilePath         = TransformFile,
                ConfigFilePath            = ConfigFile,
                TransformFileContent      = TransformFile.ReadAllText(),
                ConfigFileBeforeTransform = ConfigFile.ReadAllText(),
            };

            try
            {
                result.Success = ConfigTransform.Transform(TransformFile, ConfigFile);
                result.ConfigFileAfterTransform = ConfigFile.ReadAllText();
            }
            catch (Exception e)
            {
                result.Exception = e;//don't throw here. Let dispatcher handle errors
            }
            return(result);
        }
        private static async Task <string> DowloadFileContent(TransformOptions options, HttpClient httpClient, TransformFile file)
        {
            var uri = new Uri(options.Source + file.Src);

            try
            {
                Console.WriteLine($"Dowloading file {uri}");
                var content = await httpClient.GetStringAsync(uri);

                await File.WriteAllTextAsync($"sources/{file.Src}", content);

                return(content);
            }
            catch (HttpRequestException ex)
            {
                Console.WriteLine($"ERROR: The file {uri} can´t be dowloaded check you internet connection, the underlyin exeption was: {ex.Message}");
                return(null);
            }
        }