Compacted Builder method

Compacted the validation on frmBuilder's btnBuild_Click(object,
EventArgs) method. This is a slight optimization, but it does help
remove the repetitive else statements.
This commit is contained in:
yankejustin 2015-04-07 14:07:42 -04:00
parent d5cb5b9c92
commit e720d20811
1 changed files with 53 additions and 60 deletions

View File

@ -202,11 +202,10 @@ namespace xServer.Forms
private void btnBuild_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(txtHost.Text) && !string.IsNullOrEmpty(txtPort.Text) && !string.IsNullOrEmpty(txtDelay.Text) && !string.IsNullOrEmpty(txtPassword.Text) && !string.IsNullOrEmpty(txtMutex.Text))
{
if (!chkInstall.Checked || (chkInstall.Checked && !string.IsNullOrEmpty(txtInstallname.Text) && !string.IsNullOrEmpty(txtInstallsub.Text)))
{
if (!chkStartup.Checked || (chkStartup.Checked && !string.IsNullOrEmpty(txtRegistryKeyName.Text)))
if (!string.IsNullOrEmpty(txtHost.Text) && !string.IsNullOrEmpty(txtPort.Text) && !string.IsNullOrEmpty(txtDelay.Text) && // Connection Information
!string.IsNullOrEmpty(txtPassword.Text) && !string.IsNullOrEmpty(txtMutex.Text) && // Client Options
!chkInstall.Checked || (chkInstall.Checked && !string.IsNullOrEmpty(txtInstallname.Text) && !string.IsNullOrEmpty(txtInstallsub.Text)) && // Installation Options
!chkStartup.Checked || (chkStartup.Checked && !string.IsNullOrEmpty(txtRegistryKeyName.Text))) // Persistence and Registry Features
{
string output = string.Empty;
string icon = string.Empty;
@ -265,12 +264,6 @@ namespace xServer.Forms
else
MessageBox.Show("Please fill out all required fields!", "Builder", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
MessageBox.Show("Please fill out all required fields!", "Builder", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
MessageBox.Show("Please fill out all required fields!", "Builder", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private int GetInstallPath()
{