public override ResponseItem Read()

in src/Elastic.Clients.Elasticsearch/_Shared/Types/Core/Bulk/BulkResponseItemConverter.cs [27:145]


	public override ResponseItem Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
	{
		reader.ValidateToken(JsonTokenType.StartObject);

		reader.Read();

		reader.ValidateToken(JsonTokenType.PropertyName);

		var operation = reader.ReadPropertyName<OperationType>(options);
		reader.Read();

		reader.ValidateToken(JsonTokenType.StartObject);

		LocalJsonValue<ErrorCause?> propError = default;
		LocalJsonValue<bool?> propForcedRefresh = default;
		LocalJsonValue<InlineGet<System.Collections.Generic.IReadOnlyDictionary<string, object>>?> propGet = default;
		LocalJsonValue<string?> propId = default;
		LocalJsonValue<string> propIndex = default;
		LocalJsonValue<long?> propPrimaryTerm = default;
		LocalJsonValue<string?> propResult = default;
		LocalJsonValue<long?> propSeqNo = default;
		LocalJsonValue<ShardStatistics?> propShards = default;
		LocalJsonValue<int> propStatus = default;
		LocalJsonValue<long?> propVersion = default;

		while (reader.Read() && reader.TokenType is JsonTokenType.PropertyName)
		{
			if (propError.TryReadProperty(ref reader, options, PropError, null))
			{
				continue;
			}

			if (propForcedRefresh.TryReadProperty(ref reader, options, PropForcedRefresh, null))
			{
				continue;
			}

			if (propGet.TryReadProperty(ref reader, options, PropGet, null))
			{
				continue;
			}

			if (propId.TryReadProperty(ref reader, options, PropId, null))
			{
				continue;
			}

			if (propIndex.TryReadProperty(ref reader, options, PropIndex, null))
			{
				continue;
			}

			if (propPrimaryTerm.TryReadProperty(ref reader, options, PropPrimaryTerm, null))
			{
				continue;
			}

			if (propResult.TryReadProperty(ref reader, options, PropResult, null))
			{
				continue;
			}

			if (propSeqNo.TryReadProperty(ref reader, options, PropSeqNo, null))
			{
				continue;
			}

			if (propShards.TryReadProperty(ref reader, options, PropShards, null))
			{
				continue;
			}

			if (propStatus.TryReadProperty(ref reader, options, PropStatus, null))
			{
				continue;
			}

			if (propVersion.TryReadProperty(ref reader, options, PropVersion, null))
			{
				continue;
			}

			if (options.UnmappedMemberHandling is JsonUnmappedMemberHandling.Skip)
			{
				reader.Skip();
			}

			throw new JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'.");
		}

		reader.ValidateToken(JsonTokenType.EndObject);

		reader.Read();

		reader.ValidateToken(JsonTokenType.EndObject);

		ResponseItem result = operation switch
		{
			OperationType.Update => new BulkUpdateResponseItem(JsonConstructorSentinel.Instance),
			OperationType.Index => new BulkIndexResponseItem(JsonConstructorSentinel.Instance),
			OperationType.Delete => new BulkDeleteResponseItem(JsonConstructorSentinel.Instance),
			OperationType.Create => new CreateResponseItem(JsonConstructorSentinel.Instance),
			_ => throw new InvalidOperationException()
		};

		result.Error = propError.Value;
		result.ForcedRefresh = propForcedRefresh.Value;
		result.Get = propGet.Value;
		result.Id = propId.Value;
		result.Index = propIndex.Value;
		result.PrimaryTerm = propPrimaryTerm.Value;
		result.Result = propResult.Value;
		result.SeqNo = propSeqNo.Value;
		result.Shards = propShards.Value;
		result.Status = propStatus.Value;
		result.Version = propVersion.Value;

		return result;
	}