| | 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.Collections.Generic; |
| | 9 | | using System.Text.Json; |
| | 10 | | using Azure.Core; |
| | 11 | |
|
| | 12 | | namespace Azure.Search.Documents.Indexes.Models |
| | 13 | | { |
| | 14 | | public partial class NGramTokenizer : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | if (Optional.IsDefined(MinGram)) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("minGram"); |
| 0 | 22 | | writer.WriteNumberValue(MinGram.Value); |
| | 23 | | } |
| 0 | 24 | | if (Optional.IsDefined(MaxGram)) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("maxGram"); |
| 0 | 27 | | writer.WriteNumberValue(MaxGram.Value); |
| | 28 | | } |
| 0 | 29 | | if (Optional.IsCollectionDefined(TokenChars)) |
| | 30 | | { |
| 0 | 31 | | writer.WritePropertyName("tokenChars"); |
| 0 | 32 | | writer.WriteStartArray(); |
| 0 | 33 | | foreach (var item in TokenChars) |
| | 34 | | { |
| 0 | 35 | | writer.WriteStringValue(item.ToSerialString()); |
| | 36 | | } |
| 0 | 37 | | writer.WriteEndArray(); |
| | 38 | | } |
| 0 | 39 | | writer.WritePropertyName("@odata.type"); |
| 0 | 40 | | writer.WriteStringValue(ODataType); |
| 0 | 41 | | writer.WritePropertyName("name"); |
| 0 | 42 | | writer.WriteStringValue(Name); |
| 0 | 43 | | writer.WriteEndObject(); |
| 0 | 44 | | } |
| | 45 | |
|
| | 46 | | internal static NGramTokenizer DeserializeNGramTokenizer(JsonElement element) |
| | 47 | | { |
| 0 | 48 | | Optional<int> minGram = default; |
| 0 | 49 | | Optional<int> maxGram = default; |
| 0 | 50 | | Optional<IList<TokenCharacterKind>> tokenChars = default; |
| 0 | 51 | | string odataType = default; |
| 0 | 52 | | string name = default; |
| 0 | 53 | | foreach (var property in element.EnumerateObject()) |
| | 54 | | { |
| 0 | 55 | | if (property.NameEquals("minGram")) |
| | 56 | | { |
| 0 | 57 | | minGram = property.Value.GetInt32(); |
| 0 | 58 | | continue; |
| | 59 | | } |
| 0 | 60 | | if (property.NameEquals("maxGram")) |
| | 61 | | { |
| 0 | 62 | | maxGram = property.Value.GetInt32(); |
| 0 | 63 | | continue; |
| | 64 | | } |
| 0 | 65 | | if (property.NameEquals("tokenChars")) |
| | 66 | | { |
| 0 | 67 | | List<TokenCharacterKind> array = new List<TokenCharacterKind>(); |
| 0 | 68 | | foreach (var item in property.Value.EnumerateArray()) |
| | 69 | | { |
| 0 | 70 | | array.Add(item.GetString().ToTokenCharacterKind()); |
| | 71 | | } |
| 0 | 72 | | tokenChars = array; |
| 0 | 73 | | continue; |
| | 74 | | } |
| 0 | 75 | | if (property.NameEquals("@odata.type")) |
| | 76 | | { |
| 0 | 77 | | odataType = property.Value.GetString(); |
| 0 | 78 | | continue; |
| | 79 | | } |
| 0 | 80 | | if (property.NameEquals("name")) |
| | 81 | | { |
| 0 | 82 | | name = property.Value.GetString(); |
| | 83 | | continue; |
| | 84 | | } |
| | 85 | | } |
| 0 | 86 | | return new NGramTokenizer(odataType, name, Optional.ToNullable(minGram), Optional.ToNullable(maxGram), Optio |
| | 87 | | } |
| | 88 | | } |
| | 89 | | } |