Пример #1
0
        internal static PrioritizedFields DeserializePrioritizedFields(JsonElement element)
        {
            Optional <SemanticField>          titleField = default;
            Optional <IList <SemanticField> > prioritizedContentFields  = default;
            Optional <IList <SemanticField> > prioritizedKeywordsFields = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("titleField"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    titleField = SemanticField.DeserializeSemanticField(property.Value);
                    continue;
                }
                if (property.NameEquals("prioritizedContentFields"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <SemanticField> array = new List <SemanticField>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(SemanticField.DeserializeSemanticField(item));
                    }
                    prioritizedContentFields = array;
                    continue;
                }
                if (property.NameEquals("prioritizedKeywordsFields"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <SemanticField> array = new List <SemanticField>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(SemanticField.DeserializeSemanticField(item));
                    }
                    prioritizedKeywordsFields = array;
                    continue;
                }
            }
            return(new PrioritizedFields(titleField.Value, Optional.ToList(prioritizedContentFields), Optional.ToList(prioritizedKeywordsFields)));
        }
 internal PrioritizedFields(SemanticField titleField, IList <SemanticField> contentFields, IList <SemanticField> keywordFields)
 {
     TitleField    = titleField;
     ContentFields = contentFields;
     KeywordFields = keywordFields;
 }