AlienDwarf / open-meteo-dotnet

A .Net library for the Open-Meteo.com API.
MIT License
26 stars 9 forks source link

Make HourlyOptions and DailyOptions enumerable #7

Closed AlienDwarf closed 2 years ago

AlienDwarf commented 2 years ago

Description

Implement interface IEnumerable

Describe the solution you'd like

Possibility to use for each

DadiBit commented 2 years ago

Not sure how easy the "translation" would be, but you should be able to ease a bit the work by copying and pasting from the kotlin library. All enums are in the params subfolders, btw :smile:

AlienDwarf commented 2 years ago

Thank you for the hintπŸ˜„ I think there will be some code to recycle.

Otherwise we will still have to implement IEnumerable and probably ICollection to make for-each-loop work in c#.

Feel free to fork if you want :D

DadiBit commented 2 years ago

Otherwise we will still have to implement IEnumerable and probably ICollection to make for-each-loop work in c#.

Feel free to fork if you want :D

I'm sorry, I've never worked in C# (only a bit with .NET on PowerShell). I'm also working on the Kotlin library (which wasn't too difficult to learn, since I worked with Java and JavaScript), so it would be quite difficult for me to be of any other help.

As a sidenote: I really like the structure of this library (like the fact that you can use a place name instead of its coordinates), so I'm thinking of stealing the code structure; hope you don't mind :)

AlienDwarf commented 2 years ago

As a sidenote: I really like the structure of this library (like the fact that you can use a place name instead of its coordinates), so I'm thinking of stealing the code structure; hope you don't mind :)

No problem go ahead, keep in mind you have to make 2 requests to get weather data of a location by it's name πŸ˜„

DadiBit commented 2 years ago

I was thinking about using the main constructor with the coordinates and then overloading it with one that sets some default coordinates and then queries the geocoding API. Not sure if it could work in C#, but I think it would be a nice feature in this library as well.

AlienDwarf commented 2 years ago

I'm not sure if you meant this but WeatherForecastOptions options = new WeatherForecastOptions(); already sets latitude and longitude to 0 as default location. If you now query weather data with this options you will get weather data 😁