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, IList <LexicalNormalizer> normalizers, SearchResourceEncryptionKey encryptionKey, SimilarityAlgorithm similarity, SemanticSettings semanticSettings, string etag) { Name = name; _fields = fields; ScoringProfiles = scoringProfiles; DefaultScoringProfile = defaultScoringProfile; CorsOptions = corsOptions; Suggesters = suggesters; Analyzers = analyzers; Tokenizers = tokenizers; TokenFilters = tokenFilters; CharFilters = charFilters; Normalizers = normalizers; EncryptionKey = encryptionKey; Similarity = similarity; SemanticSettings = semanticSettings; _etag = etag; }
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)); }