internal static DeploymentPropertiesExtended DeserializeDeploymentPropertiesExtended(JsonElement element)
        {
            Optional <ProvisioningState>             provisioningState = default;
            Optional <string>                        correlationId     = default;
            Optional <DateTimeOffset>                timestamp         = default;
            Optional <string>                        duration          = default;
            Optional <object>                        outputs           = default;
            Optional <IReadOnlyList <ProviderData> > providers         = default;
            Optional <IReadOnlyList <Dependency> >   dependencies      = default;
            Optional <TemplateLink>                  templateLink      = default;
            Optional <object>                        parameters        = default;
            Optional <ParametersLink>                parametersLink    = default;
            Optional <DeploymentMode>                mode               = default;
            Optional <DebugSetting>                  debugSetting       = default;
            Optional <OnErrorDeploymentExtended>     onErrorDeployment  = default;
            Optional <string>                        templateHash       = default;
            Optional <IReadOnlyList <SubResource> >  outputResources    = default;
            Optional <IReadOnlyList <SubResource> >  validatedResources = default;
            Optional <ErrorDetail>                   error              = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("provisioningState"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    provisioningState = new ProvisioningState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("correlationId"))
                {
                    correlationId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("timestamp"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    timestamp = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("duration"))
                {
                    duration = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("outputs"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    outputs = property.Value.GetObject();
                    continue;
                }
                if (property.NameEquals("providers"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <ProviderData> array = new List <ProviderData>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(JsonSerializer.Deserialize <ProviderData>(item.ToString()));
                    }
                    providers = array;
                    continue;
                }
                if (property.NameEquals("dependencies"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <Dependency> array = new List <Dependency>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(Dependency.DeserializeDependency(item));
                    }
                    dependencies = array;
                    continue;
                }
                if (property.NameEquals("templateLink"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    templateLink = TemplateLink.DeserializeTemplateLink(property.Value);
                    continue;
                }
                if (property.NameEquals("parameters"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    parameters = property.Value.GetObject();
                    continue;
                }
                if (property.NameEquals("parametersLink"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    parametersLink = ParametersLink.DeserializeParametersLink(property.Value);
                    continue;
                }
                if (property.NameEquals("mode"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    mode = new DeploymentMode(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("debugSetting"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    debugSetting = DebugSetting.DeserializeDebugSetting(property.Value);
                    continue;
                }
                if (property.NameEquals("onErrorDeployment"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    onErrorDeployment = OnErrorDeploymentExtended.DeserializeOnErrorDeploymentExtended(property.Value);
                    continue;
                }
                if (property.NameEquals("templateHash"))
                {
                    templateHash = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("outputResources"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <SubResource> array = new List <SubResource>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(JsonSerializer.Deserialize <SubResource>(item.ToString()));
                    }
                    outputResources = array;
                    continue;
                }
                if (property.NameEquals("validatedResources"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <SubResource> array = new List <SubResource>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(JsonSerializer.Deserialize <SubResource>(item.ToString()));
                    }
                    validatedResources = array;
                    continue;
                }
                if (property.NameEquals("error"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    error = JsonSerializer.Deserialize <ErrorDetail>(property.Value.ToString());
                    continue;
                }
            }
            return(new DeploymentPropertiesExtended(Optional.ToNullable(provisioningState), correlationId.Value, Optional.ToNullable(timestamp), duration.Value, outputs.Value, Optional.ToList(providers), Optional.ToList(dependencies), templateLink.Value, parameters.Value, parametersLink.Value, Optional.ToNullable(mode), debugSetting.Value, onErrorDeployment.Value, templateHash.Value, Optional.ToList(outputResources), Optional.ToList(validatedResources), error));
        }
예제 #2
0
 public static string ToSerialString(this DeploymentMode value) => value switch
 {