/// <summary>
        /// Validates all the items present in the game configuration file, setting them to a default value if
        /// possible when the user input values are not valid.
        /// </summary>
        private void ValidateConnectionFields()
        {
            // Vnc info validation
            IValidator <string> ipValidator      = new TextValidator(_ipValidation);
            IValidator <string> textValidator    = new TextValidator();
            IValidator <int>    vncPortValidator =
                new IntegerValidator(MinPortNumberAccepted, MaxPortNumberAccepted, 5900);

            connectionConfig.vncConnectionInfo.targetHost =
                ipValidator.Validate(connectionConfig.vncConnectionInfo.targetHost);

            connectionConfig.vncConnectionInfo.port =
                vncPortValidator.Validate(connectionConfig.vncConnectionInfo.port);

            connectionConfig.vncConnectionInfo.vncServerPassword =
                textValidator.Validate(connectionConfig.vncConnectionInfo.vncServerPassword);

            // Ssh info validation

            IValidator <int> sshPortValidator =
                new IntegerValidator(MinPortNumberAccepted, MaxPortNumberAccepted, 22);

            connectionConfig.sshConnectionInfo.username =
                textValidator.Validate(connectionConfig.sshConnectionInfo.username);
            connectionConfig.sshConnectionInfo.password =
                textValidator.Validate(connectionConfig.sshConnectionInfo.password);

            connectionConfig.sshConnectionInfo.port =
                sshPortValidator.Validate(connectionConfig.sshConnectionInfo.port);

            connectionConfig.sshConnectionInfo.publicKeyAuth.path =
                textValidator.Validate(connectionConfig.sshConnectionInfo.publicKeyAuth.path);

            connectionConfig.sshConnectionInfo.publicKeyAuth.passPhrase =
                textValidator.Validate(connectionConfig.sshConnectionInfo.publicKeyAuth.passPhrase);
        }
Exemplo n.º 2
0
 protected void Submit()
 {
     validator.Validate(currentText);
 }