internal static WhatIfOperationResult DeserializeWhatIfOperationResult(JsonElement element)
        {
            string        status = default;
            ErrorResponse error  = default;
            IReadOnlyList <WhatIfChange> changes = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("status"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    status = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("error"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    error = ErrorResponse.DeserializeErrorResponse(property.Value);
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("changes"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            List <WhatIfChange> array = new List <WhatIfChange>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                if (item.ValueKind == JsonValueKind.Null)
                                {
                                    array.Add(null);
                                }
                                else
                                {
                                    array.Add(WhatIfChange.DeserializeWhatIfChange(item));
                                }
                            }
                            changes = array;
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new WhatIfOperationResult(status, error, changes));
        }
        internal static WhatIfOperationResult DeserializeWhatIfOperationResult(JsonElement element)
        {
            Optional <string>        status = default;
            Optional <ResponseError> error  = default;
            Optional <IReadOnlyList <WhatIfChange> > changes = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("status"))
                {
                    status = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("error"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    error = JsonSerializer.Deserialize <ResponseError>(property.Value.ToString());
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("changes"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <WhatIfChange> array = new List <WhatIfChange>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(WhatIfChange.DeserializeWhatIfChange(item));
                            }
                            changes = array;
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new WhatIfOperationResult(status.Value, error.Value, Optional.ToList(changes)));
        }
Example #3
0
        internal static WhatIfOperationResult DeserializeWhatIfOperationResult(JsonElement element)
        {
            Optional <string>        status = default;
            Optional <ErrorResponse> error  = default;
            Optional <IReadOnlyList <WhatIfChange> > changes = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("status"))
                {
                    status = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("error"))
                {
                    error = ErrorResponse.DeserializeErrorResponse(property.Value);
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("changes"))
                        {
                            List <WhatIfChange> array = new List <WhatIfChange>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(WhatIfChange.DeserializeWhatIfChange(item));
                            }
                            changes = array;
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new WhatIfOperationResult(status.Value, error.Value, Optional.ToList(changes)));
        }