예제 #1
0
 public static WeatherForecastWithIgnoreAttribute CreateWeatherForecastWithIgnoreAttribute()
 {
     var weatherForecast = new WeatherForecastWithIgnoreAttribute
     {
         Date = DateTime.Parse("2019-08-01"),
         TemperatureCelsius = 25,
         Summary = "Hot"
     };
     return weatherForecast;
 }
        public static void Run()
        {
            string jsonString;
            WeatherForecastWithIgnoreAttribute weatherForecast = WeatherForecastFactories.CreateWeatherForecastWithIgnoreAttribute();

            weatherForecast.DisplayPropertyValues();

            // <SnippetSerialize>
            var options = new JsonSerializerOptions
            {
                WriteIndented = true
            };

            jsonString = JsonSerializer.Serialize(weatherForecast, options);
            // </SnippetSerialize>
            Console.WriteLine(jsonString);
            Console.WriteLine();
        }
예제 #3
0
 public static void DisplayPropertyValues(this WeatherForecastWithIgnoreAttribute wf)
 {
     Utilities.DisplayPropertyValues(wf);
     Console.WriteLine();
 }