public static WeatherForecastWithROProperty CreateWeatherForecastWithROProperty() { var weatherForecast = new WeatherForecastWithROProperty { Date = DateTime.Parse("2019-08-01"), TemperatureCelsius = 25, Summary = "Hot" }; return weatherForecast; }
public static void Run() { string jsonString; WeatherForecastWithROProperty weatherForecast = WeatherForecastFactories.CreateWeatherForecastWithROProperty(); weatherForecast.DisplayPropertyValues(); // <SnippetSerialize> var options = new JsonSerializerOptions { IgnoreReadOnlyProperties = true, WriteIndented = true }; jsonString = JsonSerializer.Serialize(weatherForecast, options); // </SnippetSerialize> Console.WriteLine(jsonString); Console.WriteLine(); }
public static void DisplayPropertyValues(this WeatherForecastWithROProperty wf) { Utilities.DisplayPropertyValues(wf); Console.WriteLine(); }