internal static User DeserializeUser(JsonElement element)
        {
            Optional <string>   immutableId       = default;
            Optional <string>   usageLocation     = default;
            Optional <string>   givenName         = default;
            Optional <string>   surname           = default;
            Optional <UserType> userType          = default;
            Optional <bool>     accountEnabled    = default;
            Optional <string>   displayName       = default;
            Optional <string>   userPrincipalName = default;
            Optional <string>   mailNickname      = default;
            Optional <string>   mail = default;
            Optional <IReadOnlyList <SignInName> > signInNames                  = default;
            Optional <string>                    objectId                       = default;
            string                               objectType                     = default;
            Optional <DateTimeOffset?>           deletionTimestamp              = default;
            IReadOnlyDictionary <string, object> additionalProperties           = default;
            Dictionary <string, object>          additionalPropertiesDictionary = new Dictionary <string, object>();

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("immutableId"))
                {
                    immutableId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("usageLocation"))
                {
                    usageLocation = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("givenName"))
                {
                    givenName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("surname"))
                {
                    surname = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("userType"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    userType = new UserType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("accountEnabled"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    accountEnabled = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("displayName"))
                {
                    displayName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("userPrincipalName"))
                {
                    userPrincipalName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("mailNickname"))
                {
                    mailNickname = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("mail"))
                {
                    mail = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("signInNames"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <SignInName> array = new List <SignInName>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(SignInName.DeserializeSignInName(item));
                    }
                    signInNames = array;
                    continue;
                }
                if (property.NameEquals("objectId"))
                {
                    objectId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("objectType"))
                {
                    objectType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("deletionTimestamp"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        deletionTimestamp = null;
                        continue;
                    }
                    deletionTimestamp = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject());
            }
            additionalProperties = additionalPropertiesDictionary;
            return(new User(objectId.Value, objectType, Optional.ToNullable(deletionTimestamp), additionalProperties, immutableId.Value, usageLocation.Value, givenName.Value, surname.Value, Optional.ToNullable(userType), Optional.ToNullable(accountEnabled), displayName.Value, userPrincipalName.Value, mailNickname.Value, mail.Value, Optional.ToList(signInNames)));
        }
Ejemplo n.º 2
0
        internal static User DeserializeUser(JsonElement element)
        {
            string   immutableId       = default;
            string   usageLocation     = default;
            string   givenName         = default;
            string   surname           = default;
            UserType?userType          = default;
            bool?    accountEnabled    = default;
            string   displayName       = default;
            string   userPrincipalName = default;
            string   mailNickname      = default;
            string   mail = default;
            IReadOnlyList <SignInName> signInNames = default;
            string         objectId          = default;
            string         objectType        = default;
            DateTimeOffset?deletionTimestamp = default;
            IReadOnlyDictionary <string, object> additionalProperties           = default;
            Dictionary <string, object>          additionalPropertiesDictionary = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("immutableId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    immutableId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("usageLocation"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    usageLocation = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("givenName"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    givenName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("surname"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    surname = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("userType"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    userType = new UserType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("accountEnabled"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    accountEnabled = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("displayName"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    displayName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("userPrincipalName"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    userPrincipalName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("mailNickname"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    mailNickname = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("mail"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    mail = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("signInNames"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <SignInName> array = new List <SignInName>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(SignInName.DeserializeSignInName(item));
                        }
                    }
                    signInNames = array;
                    continue;
                }
                if (property.NameEquals("objectId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    objectId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("objectType"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    objectType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("deletionTimestamp"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    deletionTimestamp = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                additionalPropertiesDictionary ??= new Dictionary <string, object>();
                if (property.Value.ValueKind == JsonValueKind.Null)
                {
                    additionalPropertiesDictionary.Add(property.Name, null);
                }
                else
                {
                    additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject());
                }
            }
            additionalProperties = additionalPropertiesDictionary;
            return(new User(objectId, objectType, deletionTimestamp, additionalProperties, immutableId, usageLocation, givenName, surname, userType, accountEnabled, displayName, userPrincipalName, mailNickname, mail, signInNames));
        }