private void ImportFaultMessages(PaneNode operationNode, Operation operation, string originalOperationName) { if(oldOperations.Count > 0) { ImportFaultMessages(operationNode, operation, originalOperationName, oldOperations); return; } if(importedContract != null) { ImportFaultMessages(operationNode, operation, originalOperationName, importedContract.OperationsCollection); return; } if(inferOperations.Count > 0) { ImportFaultMessages(operationNode, operation, originalOperationName, inferOperations); return; } }
private void ImportFaultMessages(PaneNode operationNode, Operation operation, string originalOperationName, OperationsCollection operations) { foreach (Operation op in operations) { if (op.Name == operation.Name || (originalOperationName != string.Empty && op.Name == originalOperationName)) { foreach (Message faultMessage in op.Faults) { AddFaultPropertyPane(operationNode, operation, faultMessage); } } } }
private PaneNode AddFaultPropertyPane(PaneNode operationNode, Operation selectedOperation, Message faultMessage) { selectedOperation.Faults.Add(faultMessage); string guid = Guid.NewGuid().ToString(); PropertyPane propPaneFaultMessage = new PropertyPane(); propPaneFaultMessage.Name = "propPaneFault" + guid; propPaneFaultMessage.Text = "Fault " + faultMessage.Name; propPaneFaultMessage.Tag = selectedOperation.Name + "Fault"; // Setup dynamic GUI controls for the pane - FaultMessage Label faultMessageParameterLabel = new Label(); faultMessageParameterLabel.Location = new Point(6, 5); faultMessageParameterLabel.Name = "faultMessageParameterLabel" + guid; faultMessageParameterLabel.Size = new Size(55, 33); faultMessageParameterLabel.Text = "Message body:"; faultMessageParameterLabel.TabIndex = 0; ComboBox faultMessageParamsCombo = new ComboBox(); faultMessageParamsCombo.DropDownStyle = ComboBoxStyle.DropDownList; faultMessageParamsCombo.Location = new Point(65, 5); faultMessageParamsCombo.Name = "faultMessageParamsCombo" + guid; faultMessageParamsCombo.Size = new Size(80, 21); faultMessageParamsCombo.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; faultMessageParamsCombo.Tag = selectedOperation; faultMessageParamsCombo.TabIndex = 1; Label faultMessageNameLabel = new Label(); faultMessageNameLabel.Location = new Point(6, 48); faultMessageNameLabel.Name = "faultMessageNameLabel" + guid; faultMessageNameLabel.Text = "Message name:"; faultMessageNameLabel.AutoSize = true; TextBox faultMessageNameTextBox = new TextBox(); faultMessageNameTextBox.Location = new Point(8, 69); faultMessageNameTextBox.Name = "faultMessageNameTextBox" + guid; faultMessageNameTextBox.Size = new Size(142, 20); faultMessageNameTextBox.Text = faultMessage.Name; faultMessageNameTextBox.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; faultMessageNameTextBox.DataBindings.Add("Text", faultMessage, "Name"); faultMessageNameTextBox.TextChanged += (o, s) => propPaneFaultMessage.Text = "Fault " + faultMessageNameTextBox.Text; faultMessageNameTextBox.TabIndex = 2; foreach (SchemaElement schemaElement in faultSchemas) { faultMessageParamsCombo.Items.Add(schemaElement); } if (faultMessageParamsCombo.Items.Count > 0) { faultMessageParamsCombo.SelectedIndex = 0; } faultMessageParamsCombo.DisplayMember = "ElementName"; if (!string.IsNullOrEmpty(faultMessage.Element.ElementName)) { faultMessageParamsCombo.SelectedItem = faultMessage.Element; } faultMessageParamsCombo.SelectedIndexChanged += (o, s) => { faultMessage.Element = (SchemaElement)faultMessageParamsCombo.SelectedItem; }; LinkLabel faultRemoveLink = new LinkLabel(); faultRemoveLink.Location = new Point(6, 100); faultRemoveLink.Text = "Remove Fault Message"; faultRemoveLink.AutoSize = true; faultRemoveLink.TabIndex = 3; Label faultDocLabel = new Label(); faultDocLabel.Location = new Point(6, 125); faultDocLabel.Name = "faultDocLabel" + guid; faultDocLabel.Size = new Size(88, 23); faultDocLabel.Text = "Documentation:"; faultDocLabel.TabIndex = 4; TextBox faultDocTextBox = new TextBox(); faultDocTextBox.Location = new Point(8, 144); faultDocTextBox.Text = faultMessage.Documentation; faultDocTextBox.Multiline = true; faultDocTextBox.Name = "faultDocTextBox" + guid; faultDocTextBox.Size = new Size(142, 0); faultDocTextBox.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; faultDocTextBox.DataBindings.Add("Text", faultMessage, "Documentation"); faultDocTextBox.TabIndex = 5; propPaneFaultMessage.Controls.Add(faultMessageParameterLabel); propPaneFaultMessage.Controls.Add(faultMessageParamsCombo); propPaneFaultMessage.Controls.Add(faultMessageNameLabel); propPaneFaultMessage.Controls.Add(faultMessageNameTextBox); propPaneFaultMessage.Controls.Add(faultRemoveLink); propPaneFaultMessage.Controls.Add(faultDocTextBox); propPaneFaultMessage.Controls.Add(faultDocLabel); operationNode.Expanded = true; PaneNode faultPaneNode = operationNode.PropertyPane.PaneNodes.Add(propPaneFaultMessage); faultRemoveLink.Click += (o, s) => { selectedOperation.Faults.Remove(faultMessage); operationNode.PaneNodes.Remove(faultPaneNode); }; return faultPaneNode; }