示例#1
0
        private static JsonPropertyInfo[] PersonPropInitFunc(JsonSerializerContext context)
        {
            JsonContext           jsonContext = (JsonContext)context;
            JsonSerializerOptions options     = context.Options;

            JsonPropertyInfo[] properties = new JsonPropertyInfo[4];

            properties[0] = JsonMetadataServices.CreatePropertyInfo(
                options,
                isProperty: true,
                declaringType: typeof(Person),
                propertyTypeInfo: jsonContext.Int32,
                converter: null,
                getter: static (obj) => { return(((Person)obj).Age); },
                setter: static (obj, value) => { ((Person)obj).Age = value; },
                ignoreCondition: default,
        private static JsonPropertyInfo[] WeatherForecastWithPOCOsPropInitFunc(JsonSerializerContext context)
        {
            JsonContext           jsonContext = (JsonContext)context;
            JsonSerializerOptions options     = context.Options;

            JsonPropertyInfo[] properties = new JsonPropertyInfo[7];

            properties[0] = JsonMetadataServices.CreatePropertyInfo(
                options,
                isProperty: true,
                declaringType: typeof(WeatherForecastWithPOCOs),
                propertyTypeInfo: jsonContext.DateTimeOffset,
                converter: null,
                getter: static (obj) => { return(((WeatherForecastWithPOCOs)obj).Date); },
                setter: static (obj, value) => { ((WeatherForecastWithPOCOs)obj).Date = value; },
                ignoreCondition: default,