Exemplo n.º 1
0
        public static async void TrovaUltimoSolMarte()
        {
            int  ultimoconosciuto = Int32.Parse(LocalStorageUtility.RitornaStringa("ultimoconosciuto"));
            bool ripeti           = true;

            while (ripeti)
            {
                using (var httpClient = new System.Net.Http.HttpClient())
                {
                    ultimoconosciuto++;
                    string url = $"https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos?api_key={APIKEY}&sol={ultimoconosciuto}";

                    var stream = await httpClient.GetStreamAsync(url);

                    StreamReader reader     = new StreamReader(stream);
                    string       jsonString = reader.ReadToEnd();

                    JMars1 jm = JMars1.FromJson(jsonString);
                    if (ripeti = jm.Photos.Count > 1)
                    {
                        LocalStorageUtility.SetStringa(ultimoconosciuto.ToString(), "ultimoconosciuto");
                    }
                }
            }
        }
Exemplo n.º 2
0
 public static string ToJson(this JMars1 self) => JsonConvert.SerializeObject(self, JMars1_Converter.Settings);