Пример #1
0
        internal static LocalUserData DeserializeLocalUserData(JsonElement element)
        {
            ResourceIdentifier id         = default;
            string             name       = default;
            ResourceType       type       = default;
            SystemData         systemData = default;
            Optional <IList <PermissionScope> > permissionScopes = default;
            Optional <string> homeDirectory = default;
            Optional <IList <SshPublicKey> > sshAuthorizedKeys = default;
            Optional <string> sid            = default;
            Optional <bool>   hasSharedKey   = default;
            Optional <bool>   hasSshKey      = default;
            Optional <bool>   hasSshPassword = default;

            foreach (var property in element.EnumerateObject())
            {
                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;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("permissionScopes"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <PermissionScope> array = new List <PermissionScope>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(PermissionScope.DeserializePermissionScope(item));
                            }
                            permissionScopes = array;
                            continue;
                        }
                        if (property0.NameEquals("homeDirectory"))
                        {
                            homeDirectory = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("sshAuthorizedKeys"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <SshPublicKey> array = new List <SshPublicKey>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(SshPublicKey.DeserializeSshPublicKey(item));
                            }
                            sshAuthorizedKeys = array;
                            continue;
                        }
                        if (property0.NameEquals("sid"))
                        {
                            sid = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("hasSharedKey"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            hasSharedKey = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("hasSshKey"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            hasSshKey = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("hasSshPassword"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            hasSshPassword = property0.Value.GetBoolean();
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new LocalUserData(id, name, type, systemData, Optional.ToList(permissionScopes), homeDirectory.Value, Optional.ToList(sshAuthorizedKeys), sid.Value, Optional.ToNullable(hasSharedKey), Optional.ToNullable(hasSshKey), Optional.ToNullable(hasSshPassword)));
        }