64 lines
1.6 KiB
C#
64 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.Text.Json;
|
|
|
|
namespace CryptoCalc
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for MainWindow.xaml
|
|
/// </summary>
|
|
public partial class MainWindow : Window
|
|
{
|
|
private readonly Random rand = new();
|
|
private readonly JsonSerializerOptions jsonOptions = new();
|
|
|
|
public MainWindow()
|
|
{
|
|
InitializeComponent();
|
|
jsonOptions.WriteIndented = true;
|
|
}
|
|
|
|
private void saveButton_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
Debug.WriteLine("asdf");
|
|
|
|
var weatherForecast = new WeatherForecast
|
|
{
|
|
Date = DateTime.Parse("2019-08-01"),
|
|
TemperatureCelsius = rand.Next(0,100),
|
|
Summary = "Hot"
|
|
|
|
};
|
|
|
|
string fileName = "asdf.json";
|
|
string jsonString = JsonSerializer.Serialize(weatherForecast, jsonOptions);
|
|
File.AppendAllText(fileName, jsonString);
|
|
|
|
Debug.WriteLine(File.ReadAllText(fileName));
|
|
}
|
|
}
|
|
|
|
|
|
public class WeatherForecast
|
|
{
|
|
public DateTimeOffset Date { get; set; }
|
|
public int TemperatureCelsius { get; set; }
|
|
public string Summary { get; set; }
|
|
}
|
|
|
|
}
|