Ejemplo n.º 1
0
        internal static DeploymentResourceProperties DeserializeDeploymentResourceProperties(JsonElement element)
        {
            Optional <UserSourceInfo>     source             = default;
            Optional <DeploymentSettings> deploymentSettings = default;
            Optional <DeploymentResourceProvisioningState> provisioningState = default;
            Optional <DeploymentResourceStatus>            status            = default;
            Optional <bool> active = default;
            Optional <IReadOnlyList <DeploymentInstance> > instances = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("source"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    source = UserSourceInfo.DeserializeUserSourceInfo(property.Value);
                    continue;
                }
                if (property.NameEquals("deploymentSettings"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    deploymentSettings = DeploymentSettings.DeserializeDeploymentSettings(property.Value);
                    continue;
                }
                if (property.NameEquals("provisioningState"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    provisioningState = new DeploymentResourceProvisioningState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("status"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    status = new DeploymentResourceStatus(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("active"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    active = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("instances"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <DeploymentInstance> array = new List <DeploymentInstance>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DeploymentInstance.DeserializeDeploymentInstance(item));
                    }
                    instances = array;
                    continue;
                }
            }
            return(new DeploymentResourceProperties(source.Value, deploymentSettings.Value, Optional.ToNullable(provisioningState), Optional.ToNullable(status), Optional.ToNullable(active), Optional.ToList(instances)));
        }