AEMManager.AemInstance.Validate C# (CSharp) Method

Validate() public method

public Validate ( ) : string
return string
        public string Validate()
        {
            if (string.IsNullOrEmpty(mName)) {
            return "Please enter a name.";
              }
              if (string.IsNullOrEmpty(mHostname)) {
            return "Please enter a host name.";
              }
              if (mPort<=0) {
            return "Please enter a valid port number.";
              }
              if (string.IsNullOrEmpty(mPath)) {
            return "Please enter a path.";
              }
              if (string.IsNullOrEmpty(mUsername)) {
            return "Please enter a user name.";
              }
              if (string.IsNullOrEmpty(mPassword)) {
            return "Please enter a password.";
              }

              return null;
        }

Usage Example

Example #1
0
        private void cmOK_Click(object sender, EventArgs e)
        {
            mInstance.AemInstanceType = (AemInstanceType)Enum.GetValues(typeof(AemInstanceType)).GetValue(cboAemInstanceType.SelectedIndex);
            mInstance.Name            = txtName.Text.Trim();
            mInstance.Hostname        = txtHostname.Text.Trim();
            mInstance.Port            = ParseWithDefault(txtPort.Text, AemInstance.DEFAULT_PORT);
            mInstance.ContextPath     = txtContextPath.Text.Trim();
            mInstance.Path            = txtPath.Text.Trim();
            mInstance.JavaExecutable  = txtJavaExecutable.Text.Trim();
            mInstance.Username        = txtUsername.Text.Trim();
            mInstance.Password        = txtPassword.Text.Trim();
            if (chkRunmodePublish.Checked)
            {
                mInstance.Runmode = Runmode.PUBLISH;
            }
            else
            {
                mInstance.Runmode = Runmode.AUTHOR;
            }
            mInstance.AdditionalRunmodes   = txtAdditionalRunmodes.Text;
            mInstance.RunmodeSampleContent = chkRunmodeSampleContent.Checked;
            mInstance.IconSet            = (IconSet)Enum.GetValues(typeof(IconSet)).GetValue(cboIconSet.SelectedIndex);
            mInstance.CustomIconPath     = txtCustomIconPath.Text;
            mInstance.Password           = txtPassword.Text.Trim();
            mInstance.HeapMinSizeMb      = ParseWithDefault(txtHeapMinSizeMb.Text, AemInstance.DEFAULT_HEAP_MIN_MB);
            mInstance.HeapMaxSizeMb      = ParseWithDefault(txtHeapMaxSizeMb.Text, AemInstance.DEFAULT_HEAP_MAX_MB);
            mInstance.MaxPermSizeMb      = ParseWithDefault(txtMaxPermSizeMb.Text, AemInstance.DEFAULT_PERMSIZE_MB);
            mInstance.JVMDebug           = chkJVMDebug.Checked;
            mInstance.DebugPort          = ParseWithDefault(txtDebugPort.Text, 0);
            mInstance.JProfiler          = chkJProfiler.Checked;
            mInstance.JProfilerPort      = ParseWithDefault(txtJProfilerPort.Text, AemInstance.DEFAULT_JPROFILER_PORT);
            mInstance.JConsole           = chkJConsole.Checked;
            mInstance.JConsolePort       = ParseWithDefault(txtJConsolePort.Text, AemInstance.DEFAULT_JCONSOLE_PORT);
            mInstance.HideConfigWizard   = chkHideConfigWizards.Checked;
            mInstance.ShowInstanceWindow = chkShowInstanceWindow.Checked;
            mInstance.OpenBrowser        = chkOpenBrowser.Checked;
            mInstance.RemoteProcess      = chkRemoteProcess.Checked;
            mInstance.ShowInTaskbar      = chkShowInTaskbar.Checked;

            mInstance.CustomJVMParam1Active = chkCustomJVMParam1Active.Checked;
            mInstance.CustomJVMParam1       = txtCustomJVMParam1.Text;
            mInstance.CustomJVMParam2Active = chkCustomJVMParam2Active.Checked;
            mInstance.CustomJVMParam2       = txtCustomJVMParam2.Text;
            mInstance.CustomJVMParam3Active = chkCustomJVMParam3Active.Checked;
            mInstance.CustomJVMParam3       = txtCustomJVMParam3.Text;
            mInstance.BrowserExecutable     = txtBrowserExecutable.Text;

            string errorMessage = mInstance.Validate();

            if (errorMessage != null)
            {
                MessageBox.Show(errorMessage, "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            mInstance.Save();

            this.DialogResult = DialogResult.OK;
            this.Close();
        }