internal SearchIndex(string name, IList <SearchField> Fields, IList <ScoringProfile> scoringProfiles, string defaultScoringProfile, CorsOptions corsOptions, IList <SearchSuggester> suggesters, IList <LexicalAnalyzer> analyzers, IList <LexicalTokenizer> tokenizers, IList <TokenFilter> tokenFilters, IList <CharFilter> charFilters, SearchResourceEncryptionKey encryptionKey, SimilarityAlgorithm similarity, string Etag) { Name = name; _fields = Fields; ScoringProfiles = scoringProfiles; DefaultScoringProfile = defaultScoringProfile; CorsOptions = corsOptions; Suggesters = suggesters; Analyzers = analyzers; Tokenizers = tokenizers; TokenFilters = tokenFilters; CharFilters = charFilters; EncryptionKey = encryptionKey; Similarity = similarity; _etag = Etag; }
internal static SearchIndex DeserializeSearchIndex(JsonElement element) { string name = default; IList <SearchField> fields = default; IList <ScoringProfile> scoringProfiles = default; string defaultScoringProfile = default; CorsOptions corsOptions = default; IList <SearchSuggester> suggesters = default; IList <LexicalAnalyzer> analyzers = default; IList <LexicalTokenizer> tokenizers = default; IList <TokenFilter> tokenFilters = default; IList <CharFilter> charFilters = default; SearchResourceEncryptionKey encryptionKey = default; SimilarityAlgorithm similarity = default; string odataEtag = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("fields")) { 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 <SearchSuggester> array = new List <SearchSuggester>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(SearchSuggester.DeserializeSearchSuggester(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 = SimilarityAlgorithm.DeserializeSimilarityAlgorithm(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) { string name = default; IList <SearchField> fields = default; Optional <IList <ScoringProfile> > scoringProfiles = default; Optional <string> defaultScoringProfile = default; Optional <CorsOptions> corsOptions = default; Optional <IList <SearchSuggester> > suggesters = default; Optional <IList <LexicalAnalyzer> > analyzers = default; Optional <IList <LexicalTokenizer> > tokenizers = default; Optional <IList <TokenFilter> > tokenFilters = default; Optional <IList <CharFilter> > charFilters = default; Optional <IList <LexicalNormalizer> > normalizers = default; Optional <SearchResourceEncryptionKey> encryptionKey = default; Optional <SimilarityAlgorithm> similarity = default; Optional <SemanticSettings> semantic = default; Optional <string> odataEtag = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("fields")) { List <SearchField> array = new List <SearchField>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(SearchField.DeserializeSearchField(item)); } fields = array; continue; } if (property.NameEquals("scoringProfiles")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } List <ScoringProfile> array = new List <ScoringProfile>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(ScoringProfile.DeserializeScoringProfile(item)); } scoringProfiles = array; continue; } if (property.NameEquals("defaultScoringProfile")) { defaultScoringProfile = property.Value.GetString(); continue; } if (property.NameEquals("corsOptions")) { if (property.Value.ValueKind == JsonValueKind.Null) { corsOptions = null; continue; } corsOptions = CorsOptions.DeserializeCorsOptions(property.Value); continue; } if (property.NameEquals("suggesters")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } List <SearchSuggester> array = new List <SearchSuggester>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(SearchSuggester.DeserializeSearchSuggester(item)); } suggesters = array; continue; } if (property.NameEquals("analyzers")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } List <LexicalAnalyzer> array = new List <LexicalAnalyzer>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(LexicalAnalyzer.DeserializeLexicalAnalyzer(item)); } analyzers = array; continue; } if (property.NameEquals("tokenizers")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } List <LexicalTokenizer> array = new List <LexicalTokenizer>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(LexicalTokenizer.DeserializeLexicalTokenizer(item)); } tokenizers = array; continue; } if (property.NameEquals("tokenFilters")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } List <TokenFilter> array = new List <TokenFilter>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(TokenFilter.DeserializeTokenFilter(item)); } tokenFilters = array; continue; } if (property.NameEquals("charFilters")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } List <CharFilter> array = new List <CharFilter>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(CharFilter.DeserializeCharFilter(item)); } charFilters = array; continue; } if (property.NameEquals("normalizers")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } List <LexicalNormalizer> array = new List <LexicalNormalizer>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(LexicalNormalizer.DeserializeLexicalNormalizer(item)); } normalizers = array; continue; } if (property.NameEquals("encryptionKey")) { if (property.Value.ValueKind == JsonValueKind.Null) { encryptionKey = null; continue; } encryptionKey = SearchResourceEncryptionKey.DeserializeSearchResourceEncryptionKey(property.Value); continue; } if (property.NameEquals("similarity")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } similarity = SimilarityAlgorithm.DeserializeSimilarityAlgorithm(property.Value); continue; } if (property.NameEquals("semantic")) { if (property.Value.ValueKind == JsonValueKind.Null) { semantic = null; continue; } semantic = SemanticSettings.DeserializeSemanticSettings(property.Value); continue; } if (property.NameEquals("@odata.etag")) { odataEtag = property.Value.GetString(); continue; } } return(new SearchIndex(name, fields, Optional.ToList(scoringProfiles), defaultScoringProfile.Value, corsOptions.Value, Optional.ToList(suggesters), Optional.ToList(analyzers), Optional.ToList(tokenizers), Optional.ToList(tokenFilters), Optional.ToList(charFilters), Optional.ToList(normalizers), encryptionKey.Value, similarity.Value, semantic.Value, odataEtag.Value)); }