From: gu.martinm@gmail.com Date: Sun, 17 Aug 2014 17:20:42 +0000 (+0200) Subject: OpenWeatherMap API: always use nullable data X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=cb84d323c3262930e35529d55524e0b788ecd918;p=CSharpForFun%2F.git OpenWeatherMap API: always use nullable data In this way we can check whether we have remote received data. --- diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser.MonoDevelop.sln b/Allgemeines/openweathermap/jsonparser/jsonparser.MonoDevelop.sln new file mode 100644 index 0000000..5a7f4c4 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparser/jsonparser.MonoDevelop.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "jsonparser", "jsonparser\jsonparser.MonoDevelop.csproj", "{8F70E570-9D59-4E94-825C-62087D3BB1F6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8F70E570-9D59-4E94-825C-62087D3BB1F6}.Debug|x86.ActiveCfg = Debug|x86 + {8F70E570-9D59-4E94-825C-62087D3BB1F6}.Debug|x86.Build.0 = Debug|x86 + {8F70E570-9D59-4E94-825C-62087D3BB1F6}.Release|x86.ActiveCfg = Release|x86 + {8F70E570-9D59-4E94-825C-62087D3BB1F6}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + StartupItem = jsonparser\jsonparser.csproj + EndGlobalSection +EndGlobal diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser.Windows.sln b/Allgemeines/openweathermap/jsonparser/jsonparser.Windows.sln new file mode 100644 index 0000000..7256289 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparser/jsonparser.Windows.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.30501.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "jsonparser", "jsonparser\jsonparser.Windows.csproj", "{A49EB2A0-A969-494C-840D-A89B0989150C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A49EB2A0-A969-494C-840D-A89B0989150C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A49EB2A0-A969-494C-840D-A89B0989150C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A49EB2A0-A969-494C-840D-A89B0989150C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A49EB2A0-A969-494C-840D-A89B0989150C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser.sln b/Allgemeines/openweathermap/jsonparser/jsonparser.sln deleted file mode 100644 index df0cb7b..0000000 --- a/Allgemeines/openweathermap/jsonparser/jsonparser.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "jsonparser", "jsonparser\jsonparser.csproj", "{8F70E570-9D59-4E94-825C-62087D3BB1F6}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {8F70E570-9D59-4E94-825C-62087D3BB1F6}.Debug|x86.ActiveCfg = Debug|x86 - {8F70E570-9D59-4E94-825C-62087D3BB1F6}.Debug|x86.Build.0 = Debug|x86 - {8F70E570-9D59-4E94-825C-62087D3BB1F6}.Release|x86.ActiveCfg = Release|x86 - {8F70E570-9D59-4E94-825C-62087D3BB1F6}.Release|x86.Build.0 = Release|x86 - EndGlobalSection - GlobalSection(MonoDevelopProperties) = preSolution - StartupItem = jsonparser\jsonparser.csproj - EndGlobalSection -EndGlobal diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/App.config b/Allgemeines/openweathermap/jsonparser/jsonparser/App.config new file mode 100644 index 0000000..9c05822 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/Program.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/Program.cs index 89a7951..e9f4e13 100644 --- a/Allgemeines/openweathermap/jsonparser/jsonparser/Program.cs +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/Program.cs @@ -80,37 +80,42 @@ namespace jsonparser CurrentWeather current = JsonConvert.DeserializeObject(jsonCurrentWeatherData, _jsonSettings); - Console.WriteLine("lat: " + current.coord.lat); - Console.WriteLine("lon: " + current.coord.lon); + Console.WriteLine("lat: " + current.coord.lat ?? ""); + Console.WriteLine("lon: " + current.coord.lon ?? ""); foreach (jsonparser.currentweather.Weather weather in current.weather) { - Console.WriteLine("description: " + weather.description); - Console.WriteLine("main: " + weather.main); - Console.WriteLine("id: " + weather.id); - Console.WriteLine("icon: " + weather.icon); + Console.WriteLine("description: " + weather.description ?? ""); + Console.WriteLine("main: " + weather.main ?? ""); + Console.WriteLine("id: " + weather.id ?? ""); + Console.WriteLine("icon: " + weather.icon ?? ""); } - Console.WriteLine("humidity: " + current.main.humidity); - Console.WriteLine("pressure: " + current.main.pressure); - Console.WriteLine("temp: " + current.main.temp); - Console.WriteLine("temp_min: " + current.main.temp_min); - Console.WriteLine("temp_max: " + current.main.temp_max); - Console.WriteLine("rain: " + current.rain.get3h()); - Console.WriteLine("clouds: " + current.clouds.all); + Console.WriteLine("humidity: " + current.main.humidity ?? ""); + Console.WriteLine("pressure: " + current.main.pressure ?? ""); + Console.WriteLine("temp: " + current.main.temp ?? ""); + Console.WriteLine("temp_min: " + current.main.temp_min ?? ""); + Console.WriteLine("temp_max: " + current.main.temp_max ?? ""); + Console.WriteLine("rain: " + current.rain.get3h() ?? ""); + Console.WriteLine("clouds: " + current.clouds.all ?? ""); + + Console.ReadLine(); + ForecastWeather forecast = JsonConvert.DeserializeObject(jsonForeCastWeatherData, _jsonSettings); - Console.WriteLine("lat: " + forecast.city.coord.lat); - Console.WriteLine("lon: " + forecast.city.coord.lon); - Console.WriteLine("name: " + forecast.city.name); + Console.WriteLine("lat: " + forecast.city.coord.lat ?? ""); + Console.WriteLine("lon: " + forecast.city.coord.lon ?? ""); + Console.WriteLine("name: " + forecast.city.name ?? ""); foreach (jsonparser.forecastweather.List list in forecast.list) { - Console.WriteLine("temp day: " + list.temp.day); - Console.WriteLine("temp eve: " + list.temp.eve); - Console.WriteLine("temp max: " + list.temp.max); - Console.WriteLine("temp min: " + list.temp.min); + Console.WriteLine("temp day: " + list.temp.day ?? ""); + Console.WriteLine("temp eve: " + list.temp.eve ?? ""); + Console.WriteLine("temp max: " + list.temp.max ?? ""); + Console.WriteLine("temp min: " + list.temp.min ?? ""); } + + Console.ReadLine(); } } } diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Clouds.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Clouds.cs index e24f278..561bcaf 100644 --- a/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Clouds.cs +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Clouds.cs @@ -4,7 +4,7 @@ namespace jsonparser.currentweather { public class Clouds { - public int all { get; set; } + public int? all { get; set; } } } diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Coord.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Coord.cs index c053510..d3693b4 100644 --- a/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Coord.cs +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Coord.cs @@ -4,8 +4,8 @@ namespace jsonparser.currentweather { public class Coord { - public double lon { get; set; } - public int lat { get; set; } + public double? lon { get; set; } + public double? lat { get; set; } } } diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/CurrentWeather.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/CurrentWeather.cs index 4fec718..bb6909b 100644 --- a/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/CurrentWeather.cs +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/CurrentWeather.cs @@ -13,10 +13,10 @@ namespace jsonparser.currentweather public Wind wind { get; set; } public Rain rain { get; set; } public Clouds clouds { get; set; } - public int dt { get; set; } - public int id { get; set; } + public int? dt { get; set; } + public int? id { get; set; } public string name { get; set; } - public int cod { get; set; } + public int? cod { get; set; } } } diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Main.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Main.cs index 39a7dd9..c972bcf 100644 --- a/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Main.cs +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Main.cs @@ -4,11 +4,11 @@ namespace jsonparser.currentweather { public class Main { - public double temp { get; set; } - public int pressure { get; set; } - public int humidity { get; set; } - public double temp_min { get; set; } - public double temp_max { get; set; } + public double? temp { get; set; } + public int? pressure { get; set; } + public int? humidity { get; set; } + public double? temp_min { get; set; } + public double? temp_max { get; set; } } } diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Rain.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Rain.cs index edff969..5498788 100644 --- a/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Rain.cs +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Rain.cs @@ -4,14 +4,14 @@ namespace jsonparser.currentweather { public class Rain { - private double threeHours; + private double? threeHours; public void set3h(double three) { this.threeHours = three; } - public double get3h() + public double? get3h() { return this.threeHours; } diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Sys.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Sys.cs index 06cff86..1ea4afd 100644 --- a/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Sys.cs +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Sys.cs @@ -4,10 +4,10 @@ namespace jsonparser.currentweather { public class Sys { - public double message { get; set; } + public double? message { get; set; } public string country { get; set; } - public int sunrise { get; set; } - public int sunset { get; set; } + public int? sunrise { get; set; } + public int? sunset { get; set; } } } diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Weather.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Weather.cs index 77bfffd..bd0d5f2 100644 --- a/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Weather.cs +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Weather.cs @@ -4,7 +4,7 @@ namespace jsonparser.currentweather { public class Weather { - public int id { get; set; } + public int? id { get; set; } public string main { get; set; } public string description { get; set; } public string icon { get; set; } diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Wind.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Wind.cs index e4f1087..5aaf6d5 100644 --- a/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Wind.cs +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Wind.cs @@ -4,8 +4,8 @@ namespace jsonparser.currentweather { public class Wind { - public double speed { get; set; } - public int deg { get; set; } + public double? speed { get; set; } + public double? deg { get; set; } } } diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/City.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/City.cs index 5d301c4..11308ed 100644 --- a/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/City.cs +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/City.cs @@ -4,11 +4,11 @@ namespace jsonparser.forecastweather { public class City { - public int id { get; set; } + public int? id { get; set; } public string name { get; set; } public Coord coord { get; set; } public string country { get; set; } - public int population { get; set; } + public int? population { get; set; } } } diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/Coord.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/Coord.cs index 065cb6d..0c93ba3 100644 --- a/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/Coord.cs +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/Coord.cs @@ -4,8 +4,8 @@ namespace jsonparser.forecastweather { public class Coord { - public double lon { get; set; } - public double lat { get; set; } + public double? lon { get; set; } + public double? lat { get; set; } } } diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/ForecastWeather.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/ForecastWeather.cs index 9d29ded..eec8a54 100644 --- a/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/ForecastWeather.cs +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/ForecastWeather.cs @@ -6,9 +6,9 @@ namespace jsonparser.forecastweather public class ForecastWeather { public string cod { get; set; } - public double message { get; set; } + public double? message { get; set; } public City city { get; set; } - public int cnt { get; set; } + public int? cnt { get; set; } public List list { get; set; } } } diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/List.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/List.cs index 2d3d487..acac33b 100644 --- a/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/List.cs +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/List.cs @@ -5,15 +5,15 @@ namespace jsonparser.forecastweather { public class List { - public int dt { get; set; } + public int? dt { get; set; } public Temp temp { get; set; } - public double pressure { get; set; } - public int humidity { get; set; } + public double? pressure { get; set; } + public int? humidity { get; set; } public List weather { get; set; } - public double speed { get; set; } - public int deg { get; set; } - public int clouds { get; set; } - public double rain { get; set; } + public double? speed { get; set; } + public int? deg { get; set; } + public int? clouds { get; set; } + public double? rain { get; set; } } } diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/Temp.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/Temp.cs index dce70c2..91506f6 100644 --- a/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/Temp.cs +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/Temp.cs @@ -4,12 +4,12 @@ namespace jsonparser.forecastweather { public class Temp { - public double day { get; set; } - public double min { get; set; } - public double max { get; set; } - public double night { get; set; } - public double eve { get; set; } - public double morn { get; set; } + public double? day { get; set; } + public double? min { get; set; } + public double? max { get; set; } + public double? night { get; set; } + public double? eve { get; set; } + public double? morn { get; set; } } } diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/Weather.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/Weather.cs index 8c60109..31324eb 100644 --- a/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/Weather.cs +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/Weather.cs @@ -4,7 +4,7 @@ namespace jsonparser.forecastweather { public class Weather { - public int id { get; set; } + public int? id { get; set; } public string main { get; set; } public string description { get; set; } public string icon { get; set; } diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/jsonparser.MonoDevelop.csproj b/Allgemeines/openweathermap/jsonparser/jsonparser/jsonparser.MonoDevelop.csproj new file mode 100644 index 0000000..bd9e900 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/jsonparser.MonoDevelop.csproj @@ -0,0 +1,63 @@ + + + + Debug + x86 + 12.0.0 + 2.0 + {8F70E570-9D59-4E94-825C-62087D3BB1F6} + Exe + jsonparser + jsonparser + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + true + x86 + + + full + true + bin\Release + prompt + 4 + true + x86 + + + + + monodevelop + True + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/jsonparser.Windows.csproj b/Allgemeines/openweathermap/jsonparser/jsonparser/jsonparser.Windows.csproj new file mode 100644 index 0000000..09d90e8 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/jsonparser.Windows.csproj @@ -0,0 +1,110 @@ + + + + + Debug + AnyCPU + {A49EB2A0-A969-494C-840D-A89B0989150C} + Exe + Properties + jsonparser + jsonparser + v4.5 + 512 + publicar\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + False + ..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + False + Microsoft .NET Framework 4.5 %28x86 y x64%29 + true + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + false + + + + + \ No newline at end of file diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/jsonparser.csproj b/Allgemeines/openweathermap/jsonparser/jsonparser/jsonparser.csproj deleted file mode 100644 index bd9e900..0000000 --- a/Allgemeines/openweathermap/jsonparser/jsonparser/jsonparser.csproj +++ /dev/null @@ -1,63 +0,0 @@ - - - - Debug - x86 - 12.0.0 - 2.0 - {8F70E570-9D59-4E94-825C-62087D3BB1F6} - Exe - jsonparser - jsonparser - - - true - full - false - bin\Debug - DEBUG; - prompt - 4 - true - x86 - - - full - true - bin\Release - prompt - 4 - true - x86 - - - - - monodevelop - True - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/packages.config b/Allgemeines/openweathermap/jsonparser/jsonparser/packages.config new file mode 100644 index 0000000..992a6e6 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file