internal static SearchIndex DeserializeSearchIndex(JsonElement element) { string name = default; IList <SearchField> fields = default; IList <ScoringProfile> scoringProfiles = default; string defaultScoringProfile = default; CorsOptions corsOptions = default; IList <Suggester> suggesters = default; IList <LexicalAnalyzer> analyzers = default; IList <LexicalTokenizer> tokenizers = default; IList <TokenFilter> tokenFilters = default; IList <CharFilter> charFilters = default; SearchResourceEncryptionKey encryptionKey = default; Similarity similarity = default; string odataEtag = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } name = property.Value.GetString(); continue; } if (property.NameEquals("fields")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <SearchField> array = new List <SearchField>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(SearchField.DeserializeSearchField(item)); } } fields = array; continue; } if (property.NameEquals("scoringProfiles")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <ScoringProfile> array = new List <ScoringProfile>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(ScoringProfile.DeserializeScoringProfile(item)); } } scoringProfiles = array; continue; } if (property.NameEquals("defaultScoringProfile")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } defaultScoringProfile = property.Value.GetString(); continue; } if (property.NameEquals("corsOptions")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } corsOptions = CorsOptions.DeserializeCorsOptions(property.Value); continue; } if (property.NameEquals("suggesters")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <Suggester> array = new List <Suggester>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(Suggester.DeserializeSuggester(item)); } } suggesters = array; continue; } if (property.NameEquals("analyzers")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <LexicalAnalyzer> array = new List <LexicalAnalyzer>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(LexicalAnalyzer.DeserializeLexicalAnalyzer(item)); } } analyzers = array; continue; } if (property.NameEquals("tokenizers")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <LexicalTokenizer> array = new List <LexicalTokenizer>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(LexicalTokenizer.DeserializeLexicalTokenizer(item)); } } tokenizers = array; continue; } if (property.NameEquals("tokenFilters")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <TokenFilter> array = new List <TokenFilter>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(TokenFilter.DeserializeTokenFilter(item)); } } tokenFilters = array; continue; } if (property.NameEquals("charFilters")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <CharFilter> array = new List <CharFilter>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(CharFilter.DeserializeCharFilter(item)); } } charFilters = array; continue; } if (property.NameEquals("encryptionKey")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } encryptionKey = SearchResourceEncryptionKey.DeserializeSearchResourceEncryptionKey(property.Value); continue; } if (property.NameEquals("similarity")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } similarity = Similarity.DeserializeSimilarity(property.Value); continue; } if (property.NameEquals("@odata.etag")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } odataEtag = property.Value.GetString(); continue; } } return(new SearchIndex(name, fields, scoringProfiles, defaultScoringProfile, corsOptions, suggesters, analyzers, tokenizers, tokenFilters, charFilters, encryptionKey, similarity, odataEtag)); }
internal static SearchIndex DeserializeSearchIndex(JsonElement element) { SearchIndex result = new SearchIndex(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name")) { result.Name = property.Value.GetString(); continue; } if (property.NameEquals("fields")) { foreach (var item in property.Value.EnumerateArray()) { result.Fields.Add(SearchField.DeserializeSearchField(item)); } continue; } if (property.NameEquals("scoringProfiles")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } result.ScoringProfiles = new List <ScoringProfile>(); foreach (var item in property.Value.EnumerateArray()) { result.ScoringProfiles.Add(ScoringProfile.DeserializeScoringProfile(item)); } continue; } if (property.NameEquals("defaultScoringProfile")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } result.DefaultScoringProfile = property.Value.GetString(); continue; } if (property.NameEquals("corsOptions")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } result.CorsOptions = CorsOptions.DeserializeCorsOptions(property.Value); continue; } if (property.NameEquals("suggesters")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } result.Suggesters = new List <Suggester>(); foreach (var item in property.Value.EnumerateArray()) { result.Suggesters.Add(Suggester.DeserializeSuggester(item)); } continue; } if (property.NameEquals("analyzers")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } result.Analyzers = new List <Analyzer>(); foreach (var item in property.Value.EnumerateArray()) { result.Analyzers.Add(Analyzer.DeserializeAnalyzer(item)); } continue; } if (property.NameEquals("tokenizers")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } result.Tokenizers = new List <Tokenizer>(); foreach (var item in property.Value.EnumerateArray()) { result.Tokenizers.Add(Tokenizer.DeserializeTokenizer(item)); } continue; } if (property.NameEquals("tokenFilters")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } result.TokenFilters = new List <TokenFilter>(); foreach (var item in property.Value.EnumerateArray()) { result.TokenFilters.Add(TokenFilter.DeserializeTokenFilter(item)); } continue; } if (property.NameEquals("charFilters")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } result.CharFilters = new List <CharFilter>(); foreach (var item in property.Value.EnumerateArray()) { result.CharFilters.Add(CharFilter.DeserializeCharFilter(item)); } continue; } if (property.NameEquals("encryptionKey")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } result.EncryptionKey = EncryptionKey.DeserializeEncryptionKey(property.Value); continue; } if (property.NameEquals("@odata.etag")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } result.ETag = property.Value.GetString(); continue; } } return(result); }