コード例 #1
0
        internal static ContainerAppData DeserializeContainerAppData(JsonElement element)
        {
            Optional <ManagedServiceIdentity> identity = default;
            IDictionary <string, string>      tags     = default;
            AzureLocation      location   = default;
            ResourceIdentifier id         = default;
            string             name       = default;
            ResourceType       type       = default;
            SystemData         systemData = default;
            Optional <ContainerAppProvisioningState> provisioningState = default;
            Optional <string> managedEnvironmentId                   = default;
            Optional <string> latestRevisionName                     = default;
            Optional <string> latestRevisionFqdn                     = default;
            Optional <string> customDomainVerificationId             = default;
            Optional <ContainerAppConfiguration> configuration       = default;
            Optional <ContainerAppTemplate>      template            = default;
            Optional <IReadOnlyList <string> >   outboundIPAddresses = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("identity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    var serializeOptions = new JsonSerializerOptions {
                        Converters = { new ManagedServiceIdentityTypeV3Converter() }
                    };
                    identity = JsonSerializer.Deserialize <ManagedServiceIdentity>(property.Value.ToString(), serializeOptions);
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    tags = dictionary;
                    continue;
                }
                if (property.NameEquals("location"))
                {
                    location = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("systemData"))
                {
                    systemData = JsonSerializer.Deserialize <SystemData>(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("provisioningState"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            provisioningState = new ContainerAppProvisioningState(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("managedEnvironmentId"))
                        {
                            managedEnvironmentId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("latestRevisionName"))
                        {
                            latestRevisionName = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("latestRevisionFqdn"))
                        {
                            latestRevisionFqdn = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("customDomainVerificationId"))
                        {
                            customDomainVerificationId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("configuration"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            configuration = ContainerAppConfiguration.DeserializeContainerAppConfiguration(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("template"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            template = ContainerAppTemplate.DeserializeContainerAppTemplate(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("outboundIPAddresses"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <string> array = new List <string>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(item.GetString());
                            }
                            outboundIPAddresses = array;
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new ContainerAppData(id, name, type, systemData, tags, location, identity, Optional.ToNullable(provisioningState), managedEnvironmentId.Value, latestRevisionName.Value, latestRevisionFqdn.Value, customDomainVerificationId.Value, configuration.Value, template.Value, Optional.ToList(outboundIPAddresses)));
        }
 /// <summary>
 /// Converts the <paramref name="sourceValue" /> parameter to the <paramref name="destinationType" /> parameter using <paramref
 /// name="formatProvider" /> and <paramref name="ignoreCase" />
 /// </summary>
 /// <param name="sourceValue">the <see cref="System.Object"/> to convert from</param>
 /// <param name="destinationType">the <see cref="System.Type" /> to convert to</param>
 /// <param name="formatProvider">not used by this TypeConverter.</param>
 /// <param name="ignoreCase">when set to <c>true</c>, will ignore the case when converting.</param>
 /// <returns>
 /// an instance of <see cref="ContainerAppProvisioningState" />, or <c>null</c> if there is no suitable conversion.
 /// </returns>
 public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ContainerAppProvisioningState.CreateFrom(sourceValue);