public static run_options default_run_options() { run_options defaults = new run_options(); defaults.pet_method = "Penman-Monteith"; defaults.routing_method = "Muskingum"; return(defaults); }
static async Task run_with_options(run_options options) { // no IoC container in a console app - have to make things myself var parser = new parser(options.output_directory, options); var file_handler = new file_handler(); using var downloader = new downloader(file_handler); file_handler.ensure_that_directory_exists(options.output_directory); var all_lines_input = await file_handler .read(options.input_file) .ConfigureAwait(true); if (all_lines_input.Length == 0) { Console.WriteLine("No gravatars to download"); return; } var avatar_infos = all_lines_input .Select(_ => parser.ToAvatarInfo(_)); var distinct = avatar_infos .GroupBy(_ => _.file_name) .Select(_ => _.First()); foreach (var info in distinct) { await downloader .download_and_save_image(info) .ConfigureAwait(false); } Console.Write( $"Done. {distinct.Count()} gravatar images have been placed in " ); Console.WriteLine($"{options.output_directory}"); }
string query_string_from(run_options options) { return($"s={options.size}&d={options.gravatar_type}"); }
public parser(string output_to, run_options options) { _output_to = output_to; _query_string = query_string_from(options); }