예제 #1
0
 public static WeatherForecastWithROProperty CreateWeatherForecastWithROProperty()
 {
     var weatherForecast = new WeatherForecastWithROProperty
     {
         Date = DateTime.Parse("2019-08-01"),
         TemperatureCelsius = 25,
         Summary = "Hot"
     };
     return weatherForecast;
 }
예제 #2
0
        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();
        }
예제 #3
0
 public static void DisplayPropertyValues(this WeatherForecastWithROProperty wf)
 {
     Utilities.DisplayPropertyValues(wf);
     Console.WriteLine();
 }