/// <summary> /// Performs the validation before navigating to another page on the wizard control. /// </summary> /// <param name="sender">Source of the event.</param> /// <param name="e">An instance of <see cref="WizardPageSummaryEventArgs"/> with event data.</param> private void wsdlWizardCtrl_ValidatePage(object sender, WizardPageValidateEventArgs e) { // Validate the basic metadata. if (e.Page == wizardPageBasicMetadata) { if (tbServiceName.Text.Length == 0 || tbNamespace.Text.Length == 0) { MessageBox.Show("Please enter valid values.", "WSDL Wizard", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); e.NextPage = 1; } } // Validate the operations list. if (e.Page == wizardPageOperationsList) { if (operationsListView.Items.Count == 0) { MessageBox.Show("Please specify any operations.", "WSDL Wizard", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); e.NextPage = 3; } } // Validate the imported schemas list. if (e.Page == wizardPageSchemaImports) { if (serviceInterfaceContract.MessageSchemas.Count == 0 && importsListView.Items.Count == 0) { MessageBox.Show("Please add at least one XSD file.", "WSDL Wizard", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); e.NextPage = 2; } } }
/// <summary> /// Performs the validation before navigating to another page on the wizard control. /// </summary> /// <param name="sender">Source of the event.</param> /// <param name="e">An instance of <see cref="WizardPageSummaryEventArgs"/> with event data.</param> private void wsdlWizardCtrl_ValidatePage(object sender, WizardPageValidateEventArgs e) { // Validate the basic metadata. if(e.Page == wizardPageBasicMetadata) { if(tbServiceName.Text.Length == 0 || tbNamespace.Text.Length == 0) { MessageBox.Show("Please enter valid values.", "WSDL Wizard", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); e.NextPage = 1; } } // Validate the operations list. if(e.Page == wizardPageOperationsList) { if(operationsListView.Items.Count == 0) { MessageBox.Show("Please specify any operations.", "WSDL Wizard", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); e.NextPage = 3; } } // Validate the imported schemas list. if(e.Page == wizardPageSchemaImports) { if(messageSchemas.Count == 0 && importsListView.Items.Count == 0) { MessageBox.Show("Please add at least one XSD file.", "WSDL Wizard", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); e.NextPage = 2; } } // Validate the message mapping page. if (e.Page == wizardPageMessageMapping) { bool namelessFaultsFound = serviceInterfaceContract.OperationsCollection.OfType<Operation>() .SelectMany(operation => operation.Faults) .Where(fault => string.IsNullOrEmpty(fault.Name)) .Any(); if (namelessFaultsFound) { MessageBox.Show("Please provide a name for all fault messages.", "WSDL Wizard", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); e.NextPage = 4; return; } bool duplicateFaultForOperationFound = false; foreach (Operation operation in serviceInterfaceContract.OperationsCollection) { duplicateFaultForOperationFound |= operation.Faults .GroupBy(fault => fault.Name) .Where(grouping => grouping.Count() > 1) .Any(); } if (duplicateFaultForOperationFound) { MessageBox.Show("Please ensure that all fault messages for an operation have been given a unique name.", "WSDL Wizard", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); e.NextPage = 4; } } }