コード例 #1
0
 internal IdentityProperties(Guid?tenantId, string principalId, ManagedIdentityType managedIdentityType, IDictionary <string, UserAssignedIdentity> userAssignedIdentities)
 {
     TenantId               = tenantId;
     PrincipalId            = principalId;
     ManagedIdentityType    = managedIdentityType;
     UserAssignedIdentities = userAssignedIdentities;
 }
コード例 #2
0
        internal static IdentityProperties DeserializeIdentityProperties(JsonElement element)
        {
            Optional <Guid>     tenantId    = default;
            Optional <string>   principalId = default;
            ManagedIdentityType type        = default;
            Optional <IDictionary <string, UserAssignedIdentity> > userAssignedIdentities = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("tenantId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    tenantId = property.Value.GetGuid();
                    continue;
                }
                if (property.NameEquals("principalId"))
                {
                    principalId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = new ManagedIdentityType(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 IdentityProperties(Optional.ToNullable(tenantId), principalId.Value, type, Optional.ToDictionary(userAssignedIdentities)));
        }
コード例 #3
0
 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     writer.WritePropertyName("type");
     writer.WriteStringValue(ManagedIdentityType.ToString());
     if (Optional.IsCollectionDefined(UserAssignedIdentities))
     {
         writer.WritePropertyName("userAssignedIdentities");
         writer.WriteStartObject();
         foreach (var item in UserAssignedIdentities)
         {
             writer.WritePropertyName(item.Key);
             JsonSerializer.Serialize(writer, item.Value);
         }
         writer.WriteEndObject();
     }
     writer.WriteEndObject();
 }
コード例 #4
0
 public IdentityProperties(ManagedIdentityType managedIdentityType)
 {
     ManagedIdentityType    = managedIdentityType;
     UserAssignedIdentities = new ChangeTrackingDictionary <string, UserAssignedIdentity>();
 }