static async Task Main(string[] args) { OfflineBikeDataFetcher offlineBikeDataFetcher = new OfflineBikeDataFetcher(); RealTimeCityBikeDataFetcher realTimeCityBikeDataFetcher = new RealTimeCityBikeDataFetcher(); try { if (args[1] == "offline") { await offlineBikeDataFetcher.GetBikeCountInStation(args[0]); } if (args[1] == "realtime") { await realTimeCityBikeDataFetcher.GetBikeCountInStation(args[0]); } if (args[1] != "offline" && args[1] != "realtime") { throw new ArgumentException(String.Format(args[1])); } } catch (ArgumentException e) { Console.WriteLine("Invalid argument: " + e.Message); } }
static async Task Main(string[] args) { if (args[0] == "realtime") { RealTimeCityBikeDataFetcher querier = new RealTimeCityBikeDataFetcher(); Task <int> bikeamount = querier.GetBikeCountInStation(args[1]); Console.WriteLine("Waiting results"); int result = await bikeamount; Console.WriteLine(result); } else if (args[0] == "offline") { OfflineTimeCityBikeDataFetcher offQuerier = new OfflineTimeCityBikeDataFetcher(); Task <int> bikeamount = offQuerier.GetBikeCountInStation(args[1]); Console.WriteLine("Waiting results"); int result = await bikeamount; Console.WriteLine(result); } else { Console.WriteLine("ERROR!"); } // RealTimeCityBikeDataFetcher querier = new RealTimeCityBikeDataFetcher(); // Task<int> bikeamount = querier.GetBikeCountInStation(args[0]); // Console.WriteLine("Waiting results"); // int result = await bikeamount; // Console.WriteLine(result); }
static async Task Main(string[] args) { Console.WriteLine("Hello World!"); Console.WriteLine(args[0]); string teststring; string townstring; Console.WriteLine("do you want offline or online = off/on"); teststring = Console.ReadLine(); if (teststring == "off") { Console.WriteLine("What street are you looking for: "); townstring = Console.ReadLine(); OfflineCityBikeDataFetcher offline = new OfflineCityBikeDataFetcher(); try { Console.WriteLine(await offline.GetBikeCountInStation(townstring)); } catch (NotFoundException e) { Console.WriteLine("Not Found " + e.Message); } } if (teststring == "on") { Console.WriteLine("What street are you looking for: "); townstring = Console.ReadLine(); RealTimeCityBikeDataFetcher realTime = new RealTimeCityBikeDataFetcher(); try { Console.WriteLine(await realTime.GetBikeCountInStation(townstring)); } catch (NotFoundException e) { Console.WriteLine("Not Found " + e.Message); } } if (teststring != "off" && teststring != "on") { Console.WriteLine("wrote something else"); } }
static async Task Main(string[] args) { if (args[0] == "realtime") { RealTimeCityBikeDataFetcher querier = new RealTimeCityBikeDataFetcher(); Task <int> bikeamount = querier.GetBikeCountInStation(args[1]); Console.WriteLine("Waiting results"); int result = await bikeamount; } else if (args[0] == "offline") { OfflineCityBikeDataFetcher OfflineQuery = new OfflineCityBikeDataFetcher(); Task <int> bikeamount2 = OfflineQuery.GetBikeCountInStation(args[0]); } }
static async Task Main(string[] args) { int bikeAmount = 0; string haku = args[0]; if (args.Length > 2) { for (int i = 1; i < args.Length - 1; i++) { haku += " " + args[i]; } } //Console.WriteLine(args[0]); OfflineCityBikeDataFetcher offlinehaku = new OfflineCityBikeDataFetcher(); RealTimeCityBikeDataFetcher nettihaku = new RealTimeCityBikeDataFetcher(); if (args[args.Length - 1] == "offline") { try{ bikeAmount = await offlinehaku.GetBikeCountInStation(haku); Console.WriteLine("Täällä pyöriä onpi: " + bikeAmount); } catch (ArgumentException ex) { Console.WriteLine("Invalid argument \n" + ex.Message); } catch (NotFoundException ex) { Console.WriteLine("Not found: \n" + ex.Message); } } if (args[args.Length - 1] == "online") { try{ bikeAmount = await nettihaku.GetBikeCountInStation(haku); Console.WriteLine("Täällä pyöriä onpi: " + bikeAmount); } catch (ArgumentException ex) { Console.WriteLine("Invalid argument \n" + ex.Message); } catch (NotFoundException ex) { Console.WriteLine("Not found: \n" + ex.Message); } } }