| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System.Text.Json; |
| | 9 | | using Azure.Core; |
| | 10 | |
|
| | 11 | | namespace Azure.Search.Documents.Indexes.Models |
| | 12 | | { |
| | 13 | | public partial class PhoneticTokenFilter : IUtf8JsonSerializable |
| | 14 | | { |
| | 15 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 16 | | { |
| 0 | 17 | | writer.WriteStartObject(); |
| 0 | 18 | | if (Optional.IsDefined(Encoder)) |
| | 19 | | { |
| 0 | 20 | | writer.WritePropertyName("encoder"); |
| 0 | 21 | | writer.WriteStringValue(Encoder.Value.ToSerialString()); |
| | 22 | | } |
| 0 | 23 | | if (Optional.IsDefined(ReplaceOriginalTokens)) |
| | 24 | | { |
| 0 | 25 | | writer.WritePropertyName("replace"); |
| 0 | 26 | | writer.WriteBooleanValue(ReplaceOriginalTokens.Value); |
| | 27 | | } |
| 0 | 28 | | writer.WritePropertyName("@odata.type"); |
| 0 | 29 | | writer.WriteStringValue(ODataType); |
| 0 | 30 | | writer.WritePropertyName("name"); |
| 0 | 31 | | writer.WriteStringValue(Name); |
| 0 | 32 | | writer.WriteEndObject(); |
| 0 | 33 | | } |
| | 34 | |
|
| | 35 | | internal static PhoneticTokenFilter DeserializePhoneticTokenFilter(JsonElement element) |
| | 36 | | { |
| 0 | 37 | | Optional<PhoneticEncoder> encoder = default; |
| 0 | 38 | | Optional<bool> replace = default; |
| 0 | 39 | | string odataType = default; |
| 0 | 40 | | string name = default; |
| 0 | 41 | | foreach (var property in element.EnumerateObject()) |
| | 42 | | { |
| 0 | 43 | | if (property.NameEquals("encoder")) |
| | 44 | | { |
| 0 | 45 | | encoder = property.Value.GetString().ToPhoneticEncoder(); |
| 0 | 46 | | continue; |
| | 47 | | } |
| 0 | 48 | | if (property.NameEquals("replace")) |
| | 49 | | { |
| 0 | 50 | | replace = property.Value.GetBoolean(); |
| 0 | 51 | | continue; |
| | 52 | | } |
| 0 | 53 | | if (property.NameEquals("@odata.type")) |
| | 54 | | { |
| 0 | 55 | | odataType = property.Value.GetString(); |
| 0 | 56 | | continue; |
| | 57 | | } |
| 0 | 58 | | if (property.NameEquals("name")) |
| | 59 | | { |
| 0 | 60 | | name = property.Value.GetString(); |
| | 61 | | continue; |
| | 62 | | } |
| | 63 | | } |
| 0 | 64 | | return new PhoneticTokenFilter(odataType, name, Optional.ToNullable(encoder), Optional.ToNullable(replace)); |
| | 65 | | } |
| | 66 | | } |
| | 67 | | } |