Exemple #1
0
        internal static InstancesOperationResult DeserializeInstancesOperationResult(JsonElement element)
        {
            Optional <TimeSeriesInstance>      instance = default;
            Optional <InstancesOperationError> error    = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("instance"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    instance = TimeSeriesInstance.DeserializeTimeSeriesInstance(property.Value);
                    continue;
                }
                if (property.NameEquals("error"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    error = InstancesOperationError.DeserializeInstancesOperationError(property.Value);
                    continue;
                }
            }
            return(new InstancesOperationResult(instance.Value, error.Value));
        }
Exemple #2
0
        internal static GetInstancesPage DeserializeGetInstancesPage(JsonElement element)
        {
            Optional <IReadOnlyList <TimeSeriesInstance> > instances = default;
            Optional <string> continuationToken = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("instances"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <TimeSeriesInstance> array = new List <TimeSeriesInstance>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TimeSeriesInstance.DeserializeTimeSeriesInstance(item));
                    }
                    instances = array;
                    continue;
                }
                if (property.NameEquals("continuationToken"))
                {
                    continuationToken = property.Value.GetString();
                    continue;
                }
            }
            return(new GetInstancesPage(continuationToken.Value, Optional.ToList(instances)));
        }