MongoDBCollection IOperationSource <MongoDBCollection> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = MongoDBCollectionData.DeserializeMongoDBCollectionData(document.RootElement);

            return(new MongoDBCollection(_armClient, data));
        }
Beispiel #2
0
        internal static MongoDBCollectionListResult DeserializeMongoDBCollectionListResult(JsonElement element)
        {
            Optional <IReadOnlyList <MongoDBCollectionData> > value = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("value"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <MongoDBCollectionData> array = new List <MongoDBCollectionData>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(MongoDBCollectionData.DeserializeMongoDBCollectionData(item));
                    }
                    value = array;
                    continue;
                }
            }
            return(new MongoDBCollectionListResult(Optional.ToList(value)));
        }