public override Hash Read()

in src/managed/DiffGen/ArchiveUtility/HashJsonConverter.cs [18:66]


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

            HashAlgorithmType? type = null;
            byte[] value = null;

            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 "type":
                        type = (HashAlgorithmType)reader.GetUInt64();
                        break;
                    case "value":
                        var hashString = reader.GetString();
                        value = HexUtility.HexStringToByteArray(hashString);
                        break;
                    default:
                        throw new JsonException();
                }
            }

            if (type == null || value == null)
            {
                throw new JsonException();
            }

            return new(type.Value, value);
        }