Пример #1
0
        internal static TimeSeriesHierarchyOrError DeserializeTimeSeriesHierarchyOrError(JsonElement element)
        {
            Optional <TimeSeriesHierarchy>     hierarchy = default;
            Optional <InstancesOperationError> error     = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("hierarchy"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    hierarchy = TimeSeriesHierarchy.DeserializeTimeSeriesHierarchy(property.Value);
                    continue;
                }
                if (property.NameEquals("error"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    error = InstancesOperationError.DeserializeInstancesOperationError(property.Value);
                    continue;
                }
            }
            return(new TimeSeriesHierarchyOrError(hierarchy.Value, error.Value));
        }
Пример #2
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));
        }
Пример #3
0
        internal static HierarchiesBatchResponse DeserializeHierarchiesBatchResponse(JsonElement element)
        {
            Optional <IReadOnlyList <TimeSeriesHierarchyOrError> > @get   = default;
            Optional <IReadOnlyList <TimeSeriesHierarchyOrError> > put    = default;
            Optional <IReadOnlyList <InstancesOperationError> >    delete = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("get"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <TimeSeriesHierarchyOrError> array = new List <TimeSeriesHierarchyOrError>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TimeSeriesHierarchyOrError.DeserializeTimeSeriesHierarchyOrError(item));
                    }
                    @get = array;
                    continue;
                }
                if (property.NameEquals("put"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <TimeSeriesHierarchyOrError> array = new List <TimeSeriesHierarchyOrError>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TimeSeriesHierarchyOrError.DeserializeTimeSeriesHierarchyOrError(item));
                    }
                    put = array;
                    continue;
                }
                if (property.NameEquals("delete"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <InstancesOperationError> array = new List <InstancesOperationError>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(InstancesOperationError.DeserializeInstancesOperationError(item));
                    }
                    delete = array;
                    continue;
                }
            }
            return(new HierarchiesBatchResponse(Optional.ToList(@get), Optional.ToList(put), Optional.ToList(delete)));
        }
Пример #4
0
        internal static TsiError DeserializeTsiError(JsonElement element)
        {
            Optional <InstancesOperationError> error = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("error"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    error = InstancesOperationError.DeserializeInstancesOperationError(property.Value);
                    continue;
                }
            }
            return(new TsiError(error.Value));
        }
Пример #5
0
        // The purpose of overriding this method is to protect against an InvalidOperationException
        // that is being thrown by the generated code. More specifically, the exception is being thrown
        // when trying to deserialize the "delete" property. A coveration has started with the Time Series
        // Insights team on take a closer look on the thrown exception.

        internal static InstancesBatchResponse DeserializeInstancesBatchResponse(JsonElement element)
        {
            Optional <IReadOnlyList <InstancesOperationResult> > @get   = default;
            Optional <IReadOnlyList <InstancesOperationResult> > put    = default;
            Optional <IReadOnlyList <InstancesOperationResult> > update = default;
            Optional <IReadOnlyList <InstancesOperationError> >  delete = default;

            foreach (JsonProperty property in element.EnumerateObject())
            {
                if (property.NameEquals("get"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <InstancesOperationResult> array = new List <InstancesOperationResult>();
                    foreach (JsonElement item in property.Value.EnumerateArray())
                    {
                        array.Add(InstancesOperationResult.DeserializeInstancesOperationResult(item));
                    }
                    @get = array;
                    continue;
                }
                if (property.NameEquals("put"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <InstancesOperationResult> array = new List <InstancesOperationResult>();
                    foreach (JsonElement item in property.Value.EnumerateArray())
                    {
                        array.Add(InstancesOperationResult.DeserializeInstancesOperationResult(item));
                    }
                    put = array;
                    continue;
                }
                if (property.NameEquals("update"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <InstancesOperationResult> array = new List <InstancesOperationResult>();
                    foreach (JsonElement item in property.Value.EnumerateArray())
                    {
                        array.Add(InstancesOperationResult.DeserializeInstancesOperationResult(item));
                    }
                    update = array;
                    continue;
                }
                if (property.NameEquals("delete"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <InstancesOperationError> array = new List <InstancesOperationError>();
                    foreach (JsonElement item in property.Value.EnumerateArray())
                    {
                        array.Add(item.ValueKind != JsonValueKind.Null ? InstancesOperationError.DeserializeInstancesOperationError(item) : null);
                    }
                    delete = array;
                    continue;
                }
            }
            return(new InstancesBatchResponse(Optional.ToList(@get), Optional.ToList(put), Optional.ToList(update), Optional.ToList(delete)));
        }