private void ButtonExportConfig_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter   = "JSON File (*.json)|*.json|All Files (*.*)|*.*";
            saveFileDialog.FileName = "JimmyDeploy.json";
            if (saveFileDialog.ShowDialog() == true)
            {
                var steps      = Config.get().Steps;
                var rootObject = new Data.RootObject
                {
                    steps = steps
                };
                var stepSerialized = JsonConvert.SerializeObject(rootObject, Formatting.Indented, new JsonSerializerSettings
                {
                    DefaultValueHandling = DefaultValueHandling.Ignore
                });
                File.WriteAllText(saveFileDialog.FileName, stepSerialized);
            }
        }
Beispiel #2
0
        public async Task <Data.RootObject> GetWeather(string cityName)
        {
            Data.RootObject result = null;
            try
            {
                var link = BaseUrl + cityName + Key;
                var json = await httpClient.GetAsync(link);

                if (json.IsSuccessStatusCode)
                {
                    var jsonContent = await json.Content.ReadAsStringAsync();

                    result = JsonConvert.DeserializeObject <Data.RootObject>(jsonContent);
                }
            }
            catch (System.Exception)
            {
            }
            return(result);
        }