internal static Models DeserializeModels(JsonElement element)
        {
            Optional <ModelsSummary> summary = default;
            Optional <IReadOnlyList <CustomFormModelInfo> > modelList = default;
            Optional <string> nextLink = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("summary"))
                {
                    summary = ModelsSummary.DeserializeModelsSummary(property.Value);
                    continue;
                }
                if (property.NameEquals("modelList"))
                {
                    List <CustomFormModelInfo> array = new List <CustomFormModelInfo>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(CustomFormModelInfo.DeserializeCustomFormModelInfo(item));
                    }
                    modelList = array;
                    continue;
                }
                if (property.NameEquals("nextLink"))
                {
                    nextLink = property.Value.GetString();
                    continue;
                }
            }
            return(new Models(summary.Value, Optional.ToList(modelList), nextLink.Value));
        }
Exemple #2
0
        internal static Models DeserializeModels(JsonElement element)
        {
            ModelsSummary             summary   = default;
            IReadOnlyList <ModelInfo> modelList = default;
            string nextLink = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("summary"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    summary = ModelsSummary.DeserializeModelsSummary(property.Value);
                    continue;
                }
                if (property.NameEquals("modelList"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <ModelInfo> array = new List <ModelInfo>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(ModelInfo.DeserializeModelInfo(item));
                        }
                    }
                    modelList = array;
                    continue;
                }
                if (property.NameEquals("nextLink"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    nextLink = property.Value.GetString();
                    continue;
                }
            }
            return(new Models(summary, modelList, nextLink));
        }
Exemple #3
0
 internal Models(ModelsSummary summary, IReadOnlyList <ModelInfo> modelList, string nextLink)
 {
     Summary   = summary;
     ModelList = modelList;
     NextLink  = nextLink;
 }