Ejemplo n.º 1
0
 internal AppPlatformAppResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, AppResourceProperties properties, ManagedServiceIdentity identity, AzureLocation?location) : base(id, name, resourceType, systemData)
 {
     Properties = properties;
     Identity   = identity;
     Location   = location;
 }
Ejemplo n.º 2
0
        internal static AppPlatformAppResourceData DeserializeAppPlatformAppResourceData(JsonElement element)
        {
            Optional <AppResourceProperties>  properties = default;
            Optional <ManagedServiceIdentity> identity   = default;
            Optional <AzureLocation>          location   = default;
            ResourceIdentifier id         = default;
            string             name       = default;
            ResourceType       type       = default;
            SystemData         systemData = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    properties = AppResourceProperties.DeserializeAppResourceProperties(property.Value);
                    continue;
                }
                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("location"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    location = new AzureLocation(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 = new ResourceType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("systemData"))
                {
                    systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString());
                    continue;
                }
            }
            return(new AppPlatformAppResourceData(id, name, type, systemData, properties.Value, identity, Optional.ToNullable(location)));
        }