Example #1
0
        internal static PhoneticTokenFilter DeserializePhoneticTokenFilter(JsonElement element)
        {
            PhoneticTokenFilter result = new PhoneticTokenFilter();

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("encoder"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    result.Encoder = property.Value.GetString().ToPhoneticEncoder();
                    continue;
                }
                if (property.NameEquals("replace"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    result.ReplaceOriginalTokens = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("@odata.type"))
                {
                    result.ODataType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    result.Name = property.Value.GetString();
                    continue;
                }
            }
            return(result);
        }
        internal static TokenFilter DeserializeTokenFilter(JsonElement element)
        {
            if (element.TryGetProperty("@odata.type", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "#Microsoft.Azure.Search.AsciiFoldingTokenFilter": return(AsciiFoldingTokenFilter.DeserializeAsciiFoldingTokenFilter(element));

                case "#Microsoft.Azure.Search.CjkBigramTokenFilter": return(CjkBigramTokenFilter.DeserializeCjkBigramTokenFilter(element));

                case "#Microsoft.Azure.Search.CommonGramTokenFilter": return(CommonGramTokenFilter.DeserializeCommonGramTokenFilter(element));

                case "#Microsoft.Azure.Search.DictionaryDecompounderTokenFilter": return(DictionaryDecompounderTokenFilter.DeserializeDictionaryDecompounderTokenFilter(element));

                case "#Microsoft.Azure.Search.EdgeNGramTokenFilter": return(EdgeNGramTokenFilter.DeserializeEdgeNGramTokenFilter(element));

                case "#Microsoft.Azure.Search.EdgeNGramTokenFilterV2": return(EdgeNGramTokenFilterV2.DeserializeEdgeNGramTokenFilterV2(element));

                case "#Microsoft.Azure.Search.ElisionTokenFilter": return(ElisionTokenFilter.DeserializeElisionTokenFilter(element));

                case "#Microsoft.Azure.Search.KeepTokenFilter": return(KeepTokenFilter.DeserializeKeepTokenFilter(element));

                case "#Microsoft.Azure.Search.KeywordMarkerTokenFilter": return(KeywordMarkerTokenFilter.DeserializeKeywordMarkerTokenFilter(element));

                case "#Microsoft.Azure.Search.LengthTokenFilter": return(LengthTokenFilter.DeserializeLengthTokenFilter(element));

                case "#Microsoft.Azure.Search.LimitTokenFilter": return(LimitTokenFilter.DeserializeLimitTokenFilter(element));

                case "#Microsoft.Azure.Search.NGramTokenFilter": return(NGramTokenFilter.DeserializeNGramTokenFilter(element));

                case "#Microsoft.Azure.Search.NGramTokenFilterV2": return(NGramTokenFilterV2.DeserializeNGramTokenFilterV2(element));

                case "#Microsoft.Azure.Search.PatternCaptureTokenFilter": return(PatternCaptureTokenFilter.DeserializePatternCaptureTokenFilter(element));

                case "#Microsoft.Azure.Search.PatternReplaceTokenFilter": return(PatternReplaceTokenFilter.DeserializePatternReplaceTokenFilter(element));

                case "#Microsoft.Azure.Search.PhoneticTokenFilter": return(PhoneticTokenFilter.DeserializePhoneticTokenFilter(element));

                case "#Microsoft.Azure.Search.ShingleTokenFilter": return(ShingleTokenFilter.DeserializeShingleTokenFilter(element));

                case "#Microsoft.Azure.Search.SnowballTokenFilter": return(SnowballTokenFilter.DeserializeSnowballTokenFilter(element));

                case "#Microsoft.Azure.Search.StemmerOverrideTokenFilter": return(StemmerOverrideTokenFilter.DeserializeStemmerOverrideTokenFilter(element));

                case "#Microsoft.Azure.Search.StemmerTokenFilter": return(StemmerTokenFilter.DeserializeStemmerTokenFilter(element));

                case "#Microsoft.Azure.Search.StopwordsTokenFilter": return(StopwordsTokenFilter.DeserializeStopwordsTokenFilter(element));

                case "#Microsoft.Azure.Search.SynonymTokenFilter": return(SynonymTokenFilter.DeserializeSynonymTokenFilter(element));

                case "#Microsoft.Azure.Search.TruncateTokenFilter": return(TruncateTokenFilter.DeserializeTruncateTokenFilter(element));

                case "#Microsoft.Azure.Search.UniqueTokenFilter": return(UniqueTokenFilter.DeserializeUniqueTokenFilter(element));

                case "#Microsoft.Azure.Search.WordDelimiterTokenFilter": return(WordDelimiterTokenFilter.DeserializeWordDelimiterTokenFilter(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 TokenFilter(odataType, name));
        }