public override Recipe Read()

in src/managed/DiffGen/ArchiveUtility/RecipeJsonConverter.cs [18:73]


        public override Recipe Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            reader.CheckStartObject();

            string name = null;
            ItemDefinition result = null;
            List<UInt64> numbers = new();
            List<ItemDefinition> items = new();

            while (reader.Read())
            {
                if (reader.TokenType == JsonTokenType.EndObject)
                {
                    break;
                }

                if (reader.TokenType != JsonTokenType.PropertyName)
                {
                    throw new JsonException();
                }

                string property = reader.GetString();

                if (property == null)
                {
                    throw new JsonException();
                }

                reader.Read();

                switch (property)
                {
                    case "Name":
                        name = reader.GetString();
                        break;
                    case "Result":
                        result = JsonSerializer.Deserialize<ItemDefinition>(ref reader, options);
                        break;
                    case "NumberIngredients":
                        numbers = JsonSerializer.Deserialize<List<UInt64>>(ref reader, options);
                        break;
                    case "ItemIngredients":
                        items = JsonSerializer.Deserialize<List<ItemDefinition>>(ref reader, options);
                        break;
                    default:
                        throw new JsonException();
                }
            }

            if (name == null || result == null)
            {
                throw new JsonException();
            }

            return new(name, result, numbers, items);
        }