private static void DisplayValidationResult(PluginValidationResult result) { if (result.Succeeded) { MessageBox.Show("Validation successful.", "Validation Result", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Validation failed:\n" + string.Join("\n", result.ErrorMessages), "Validation Result", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void saveToolStripButton_Click(object sender, EventArgs e) { try { PluginValidationResult result = PluginValidate(); if (!result.Succeeded) { DisplayValidationResult(result); return; } } catch (NotImplementedException) { // Do nothing - the plugin does not have validation code yet } PluginConfigurationData configurationData = PluginGetConfiguration(); AddConfigurationData(configurationData); SetUnsavedChanges(false); }
/// <summary> /// Validates this control. /// </summary> /// <returns>A <see cref="ValidationResult" /> representing the outcome of validation.</returns> public virtual ValidationResult Validate() { bool pluginValidationSuccess = true; StringBuilder builder = new StringBuilder(); ValidationResult hasNameResult = fieldValidator.Validate(name_TextBox); if (!hasNameResult.Succeeded) { builder.AppendLine(hasNameResult.Message); } PluginValidationResult pluginResult = _editor.ValidateConfiguration(); if (!pluginResult.Succeeded) { pluginValidationSuccess = false; builder.Append(string.Join("\n", pluginResult.ErrorMessages)); } return(new ValidationResult(pluginValidationSuccess && hasNameResult.Succeeded, builder.ToString().TrimEnd())); }
/// <summary> /// Validates the configuration data present in this control. /// </summary> /// <returns>A <see cref="PluginValidationResult" /> indicating the result of validation.</returns> public PluginValidationResult ValidateConfiguration() { PluginValidationResult result = new PluginValidationResult(fieldValidator.ValidateAll()); _activityData.HpacConfigTile = EnumUtil.Parse <HpacTile>(hpacTileCombobox.SelectedItem.ToString(), true); if (_activityData.HpacConfigTile == HpacTile.Devices) { var deviceUserControlresult = deviceUserControl.AddValidaton(); irmUserControl.RemoveValidation(); printServerUserControl.RemoveValidation(); settingsUserControl.RemoveValidation(); jobAccountingUserControl.RemoveValidation(); if (deviceUserControlresult.Succeeded & result.Succeeded) { return(new PluginValidationResult(true)); } else { return(new PluginValidationResult(false)); } } else if (_activityData.HpacConfigTile == HpacTile.IRM) { var irmUserControllresult = irmUserControl.AddValidaton(); deviceUserControl.RemoveValidation(); printServerUserControl.RemoveValidation(); settingsUserControl.RemoveValidation(); jobAccountingUserControl.RemoveValidation(); if (irmUserControllresult.Succeeded & result.Succeeded) { return(new PluginValidationResult(true)); } else { return(new PluginValidationResult(false)); } } else if (_activityData.HpacConfigTile == HpacTile.PrintServer) { var printServerUserControlresult = printServerUserControl.AddValidaton(); deviceUserControl.RemoveValidation(); irmUserControl.RemoveValidation(); settingsUserControl.RemoveValidation(); jobAccountingUserControl.RemoveValidation(); if (printServerUserControlresult.Succeeded & result.Succeeded) { return(new PluginValidationResult(true)); } else { return(new PluginValidationResult(false)); } } else if (_activityData.HpacConfigTile == HpacTile.Settings) { var settingsUserControlresult = settingsUserControl.AddValidaton(); deviceUserControl.RemoveValidation(); irmUserControl.RemoveValidation(); printServerUserControl.RemoveValidation(); jobAccountingUserControl.RemoveValidation(); if (settingsUserControlresult.Succeeded & result.Succeeded) { return(new PluginValidationResult(true)); } else { return(new PluginValidationResult(false)); } } else if (_activityData.HpacConfigTile == HpacTile.JobAccounting) { var jobAccountingUserControlresult = jobAccountingUserControl.AddValidaton(); deviceUserControl.RemoveValidation(); irmUserControl.RemoveValidation(); printServerUserControl.RemoveValidation(); settingsUserControl.RemoveValidation(); if (jobAccountingUserControlresult.Succeeded & result.Succeeded) { return(new PluginValidationResult(true)); } else { return(new PluginValidationResult(false)); } } else { return(new PluginValidationResult(fieldValidator.ValidateAll())); } }
private void validateToolStripButton_Click(object sender, EventArgs e) { PluginValidationResult result = PluginValidate(); DisplayValidationResult(result); }
public PluginValidationResult ValidateConfiguration() { PluginValidationResult result = new PluginValidationResult(fieldValidator.ValidateAll()); return(result); }