internal static ManagedServiceIdentity DeserializeManagedServiceIdentity(JsonElement element)
        {
            Optional <ManagedServiceIdentityType> type = default;
            Optional <IDictionary <string, UserAssignedIdentity> > userAssignedIdentities = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("type"))
                {
                    type = new ManagedServiceIdentityType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("userAssignedIdentities"))
                {
                    Dictionary <string, UserAssignedIdentity> dictionary = new Dictionary <string, UserAssignedIdentity>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, UserAssignedIdentity.DeserializeUserAssignedIdentity(property0.Value));
                    }
                    userAssignedIdentities = dictionary;
                    continue;
                }
            }
            return(new ManagedServiceIdentity(Optional.ToNullable(type), Optional.ToDictionary(userAssignedIdentities)));
        }
Ejemplo n.º 2
0
        internal static ManagedServiceIdentity DeserializeManagedServiceIdentity(JsonElement element)
        {
            Optional <ManagedServiceIdentityType> type = default;
            Optional <string> tenantId = default;
            Optional <IDictionary <string, UserAssignedIdentity> > userAssignedIdentities = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("type"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    type = new ManagedServiceIdentityType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("tenantId"))
                {
                    tenantId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("userAssignedIdentities"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    Dictionary <string, UserAssignedIdentity> dictionary = new Dictionary <string, UserAssignedIdentity>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, JsonSerializer.Deserialize <UserAssignedIdentity>(property0.Value.ToString()));
                    }
                    userAssignedIdentities = dictionary;
                    continue;
                }
            }
            return(new ManagedServiceIdentity(Optional.ToNullable(type), tenantId.Value, Optional.ToDictionary(userAssignedIdentities)));
        }