Пример #1
0
        internal static CharFilter DeserializeCharFilter(JsonElement element)
        {
            if (element.TryGetProperty("@odata.type", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "#Microsoft.Azure.Search.MappingCharFilter": return(MappingCharFilter.DeserializeMappingCharFilter(element));

                case "#Microsoft.Azure.Search.PatternReplaceCharFilter": return(PatternReplaceCharFilter.DeserializePatternReplaceCharFilter(element));
                }
            }
            CharFilter result = new CharFilter();

            foreach (var property in element.EnumerateObject())
            {
                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 PatternReplaceCharFilter DeserializePatternReplaceCharFilter(JsonElement element)
        {
            PatternReplaceCharFilter result = new PatternReplaceCharFilter();

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("pattern"))
                {
                    result.Pattern = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("replacement"))
                {
                    result.Replacement = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("@odata.type"))
                {
                    result.ODataType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    result.Name = property.Value.GetString();
                    continue;
                }
            }
            return(result);
        }