示例#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();
 }