| | 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 CustomAnalyzer : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | writer.WritePropertyName("tokenizer"); |
| 0 | 20 | | writer.WriteStringValue(TokenizerName.ToString()); |
| 0 | 21 | | if (Optional.IsCollectionDefined(TokenFilters)) |
| | 22 | | { |
| 0 | 23 | | writer.WritePropertyName("tokenFilters"); |
| 0 | 24 | | writer.WriteStartArray(); |
| 0 | 25 | | foreach (var item in TokenFilters) |
| | 26 | | { |
| 0 | 27 | | writer.WriteStringValue(item.ToString()); |
| | 28 | | } |
| 0 | 29 | | writer.WriteEndArray(); |
| | 30 | | } |
| 0 | 31 | | if (Optional.IsCollectionDefined(CharFilters)) |
| | 32 | | { |
| 0 | 33 | | writer.WritePropertyName("charFilters"); |
| 0 | 34 | | writer.WriteStartArray(); |
| 0 | 35 | | foreach (var item in CharFilters) |
| | 36 | | { |
| 0 | 37 | | writer.WriteStringValue(item); |
| | 38 | | } |
| 0 | 39 | | writer.WriteEndArray(); |
| | 40 | | } |
| 0 | 41 | | writer.WritePropertyName("@odata.type"); |
| 0 | 42 | | writer.WriteStringValue(ODataType); |
| 0 | 43 | | writer.WritePropertyName("name"); |
| 0 | 44 | | writer.WriteStringValue(Name); |
| 0 | 45 | | writer.WriteEndObject(); |
| 0 | 46 | | } |
| | 47 | |
|
| | 48 | | internal static CustomAnalyzer DeserializeCustomAnalyzer(JsonElement element) |
| | 49 | | { |
| 0 | 50 | | LexicalTokenizerName tokenizer = default; |
| 0 | 51 | | Optional<IList<TokenFilterName>> tokenFilters = default; |
| 0 | 52 | | Optional<IList<string>> charFilters = default; |
| 0 | 53 | | string odataType = default; |
| 0 | 54 | | string name = default; |
| 0 | 55 | | foreach (var property in element.EnumerateObject()) |
| | 56 | | { |
| 0 | 57 | | if (property.NameEquals("tokenizer")) |
| | 58 | | { |
| 0 | 59 | | tokenizer = new LexicalTokenizerName(property.Value.GetString()); |
| 0 | 60 | | continue; |
| | 61 | | } |
| 0 | 62 | | if (property.NameEquals("tokenFilters")) |
| | 63 | | { |
| 0 | 64 | | List<TokenFilterName> array = new List<TokenFilterName>(); |
| 0 | 65 | | foreach (var item in property.Value.EnumerateArray()) |
| | 66 | | { |
| 0 | 67 | | array.Add(new TokenFilterName(item.GetString())); |
| | 68 | | } |
| 0 | 69 | | tokenFilters = array; |
| 0 | 70 | | continue; |
| | 71 | | } |
| 0 | 72 | | if (property.NameEquals("charFilters")) |
| | 73 | | { |
| 0 | 74 | | List<string> array = new List<string>(); |
| 0 | 75 | | foreach (var item in property.Value.EnumerateArray()) |
| | 76 | | { |
| 0 | 77 | | array.Add(item.GetString()); |
| | 78 | | } |
| 0 | 79 | | charFilters = array; |
| 0 | 80 | | continue; |
| | 81 | | } |
| 0 | 82 | | if (property.NameEquals("@odata.type")) |
| | 83 | | { |
| 0 | 84 | | odataType = property.Value.GetString(); |
| 0 | 85 | | continue; |
| | 86 | | } |
| 0 | 87 | | if (property.NameEquals("name")) |
| | 88 | | { |
| 0 | 89 | | name = property.Value.GetString(); |
| | 90 | | continue; |
| | 91 | | } |
| | 92 | | } |
| 0 | 93 | | return new CustomAnalyzer(odataType, name, tokenizer, Optional.ToList(tokenFilters), Optional.ToList(charFil |
| | 94 | | } |
| | 95 | | } |
| | 96 | | } |