internal static LexicalTokenizer DeserializeLexicalTokenizer(JsonElement element) { if (element.TryGetProperty("@odata.type", out JsonElement discriminator)) { switch (discriminator.GetString()) { case "#Microsoft.Azure.Search.ClassicTokenizer": return(ClassicTokenizer.DeserializeClassicTokenizer(element)); case "#Microsoft.Azure.Search.EdgeNGramTokenizer": return(EdgeNGramTokenizer.DeserializeEdgeNGramTokenizer(element)); case "#Microsoft.Azure.Search.KeywordTokenizer": return(KeywordTokenizer.DeserializeKeywordTokenizer(element)); case "#Microsoft.Azure.Search.KeywordTokenizerV2": return(KeywordTokenizerV2.DeserializeKeywordTokenizerV2(element)); case "#Microsoft.Azure.Search.MicrosoftLanguageStemmingTokenizer": return(MicrosoftLanguageStemmingTokenizer.DeserializeMicrosoftLanguageStemmingTokenizer(element)); case "#Microsoft.Azure.Search.MicrosoftLanguageTokenizer": return(MicrosoftLanguageTokenizer.DeserializeMicrosoftLanguageTokenizer(element)); case "#Microsoft.Azure.Search.NGramTokenizer": return(NGramTokenizer.DeserializeNGramTokenizer(element)); case "#Microsoft.Azure.Search.PathHierarchyTokenizerV2": return(PathHierarchyTokenizerV2.DeserializePathHierarchyTokenizerV2(element)); case "#Microsoft.Azure.Search.PatternTokenizer": return(PatternTokenizer.DeserializePatternTokenizer(element)); case "#Microsoft.Azure.Search.StandardTokenizer": return(LuceneStandardTokenizer.DeserializeLuceneStandardTokenizer(element)); case "#Microsoft.Azure.Search.StandardTokenizerV2": return(LuceneStandardTokenizerV2.DeserializeLuceneStandardTokenizerV2(element)); case "#Microsoft.Azure.Search.UaxUrlEmailTokenizer": return(UaxUrlEmailTokenizer.DeserializeUaxUrlEmailTokenizer(element)); } } string odataType = default; string name = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("@odata.type")) { odataType = property.Value.GetString(); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } } return(new LexicalTokenizer(odataType, name)); }
internal static PatternTokenizer DeserializePatternTokenizer(JsonElement element) { PatternTokenizer result = new PatternTokenizer(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("pattern")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } result.Pattern = property.Value.GetString(); continue; } if (property.NameEquals("flags")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } result.Flags = new RegexFlags(property.Value.GetString()); continue; } if (property.NameEquals("group")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } result.Group = property.Value.GetInt32(); continue; } if (property.NameEquals("@odata.type")) { result.ODataType = property.Value.GetString(); continue; } if (property.NameEquals("name")) { result.Name = property.Value.GetString(); continue; } } return(result); }