/// <summary> /// Prompts a dialog box to select the new header. Once it is selected this method adds it to /// <see cref="Message.HeadersCollection"/>. Also this method creates a new <see cref="Message"/> /// for the header and puts it to the <see cref="Operation.MessagesCollection"/>. /// </summary> private void AddNewHeader() { SchemaElement newHeaderMessage = new SchemaElement(); SelectHeaderDialog dialog = new SelectHeaderDialog(this.headerElements, ref newHeaderMessage); dialog.ShowDialog(); if(newHeaderMessage.ElementName != null) { // First check whether the header already exists. And remove it if it does. foreach(Message msg in this.headerMessages) { if(newHeaderMessage.ElementName == msg.Element.ElementName && newHeaderMessage.ElementNamespace == msg.Element.ElementNamespace) { // Set the last item before returning. SelectTheLatestHeader(); return; // Exit without adding. } } string headerName = ""; int index = 1; while(headerName == "") { headerName = currentMessage.Name + "Header" + index.ToString(); foreach(MessageHeader hdr in currentMessage.HeadersCollection) { if(hdr.Name == headerName) { headerName = ""; index++; break; } } } // Create the header message. headerMessage = new Message(); headerMessage.Name = headerName; // currentMessage.Name + "Header" + headerNo; headerMessage.Documentation = ""; headerMessage.Element.ElementName = newHeaderMessage.ElementName; headerMessage.Element.ElementNamespace = newHeaderMessage.ElementNamespace; // Create the header. MessageHeader newHeader = new MessageHeader(); newHeader.Message = headerMessage.Name; newHeader.Name = headerMessage.Name; // Add header to the current message. currentMessage.HeadersCollection.Add(newHeader); // Add the new header message to the messages collection. currentOperation.MessagesCollection.Add(headerMessage); // Added the newly created header message to the header messages collection. // Reason: In case we need to remove the header messages we need to distinguish // them from the existing messages. this.headerMessages.Add(headerMessage); // Add the newly added header info to the headers combo box. currentComboBox.Items.Insert(currentComboBox.Items.Count - 1, headerMessage.Element.ElementName); // Set the last selected header message as the default header. currentComboBox.SelectedIndex = currentComboBox.Items.Count - 2; } }
/// <summary> /// Initializes a new instance of MessageDocumentationTextBoxController class with specified values. /// </summary> /// <param name="documentationTextBox">Reference to the text box control which contains the documentation.</param> /// <param name="message">Reference to an instance of <see cref="Message"/> class which belongs the documentation.</param> public MessageDocumentationTextBoxController(TextBox documentationTextBox, Message message) { this.currentTextBox = documentationTextBox; this.message = message; // Attach the event handlers. currentTextBox.TextChanged += new EventHandler(TextBox_TextChanged); }
/// <summary> /// Initializes a new instance of MessageNameTextBoxController class with the specified values. /// </summary> /// <param name="messageNameTextBox">Reference to the text box which contains the message name.</param> /// <param name="messageNameCheckBox">Reference to the check box which indicates whether the customized message name is used or not.</param> /// <param name="message">Reference to the current <see cref="Message"/>.</param> /// <param name="messageLabel">Reference to the tree view node which displays the message name.</param> public MessageNameTextBoxController(TextBox messageNameTextBox, CheckBox messageNameCheckBox, Message message, PropertyPane messageLabel) { currentTextBox = messageNameTextBox; currentCheckBox = messageNameCheckBox; currentMessageLabel = messageLabel; initialName = currentTextBox.Text; this.message = message; // Attach the event handlers for the controls. currentCheckBox.CheckedChanged += new EventHandler(CheckBox_CheckedChanged); currentTextBox.TextChanged += new EventHandler(TextBox_TextChanged); }
/// <summary> /// Initializes a new instance of OutHeaderComboBoxController class with specified values. /// </summary> /// <param name="headerComboBox">Reference to the combo box which contains the headers.</param> /// <param name="headerCheckBox">Reference to the check box which indicates whether to use the message header(s) or not.</param> /// <param name="messageNameTextBox">Reference to the text box which contains the customized message name.</param> /// <param name="operation">Reference to the instance of <see cref="Operation"/> class, <see cref="MessageHeader"/> belongs to.</param> /// <param name="message">Reference to the instance of <see cref="Message"/> class, <see cref="MessageHeader"/> belongs to.</param> /// <param name="header">Reference to the current <see cref="MessageHeader"/> of the message.</param> /// <param name="headerElements">Reference to an instance of <see cref="SchemaElements"/> class with schema elements for headers.</param> /// <param name="removeButton">Reference to the link label control used to remove headers.</param> /// <param name="addedMessages">Reference to an instance of <see cref="MessagesCollection"/> class with <see cref="Message"/> objects added for the header.</param> public OutHeaderComboBoxController(ComboBox headerComboBox, CheckBox headerCheckBox, TextBox messageNameTextBox, Operation operation, Message message, MessageHeader header, List<SchemaElement> headerElements, LinkLabel removeButton, IEnumerable<Message> addedMessages) { currentComboBox = headerComboBox; currentCheckBox = headerCheckBox; currentMessageNameTextBox = messageNameTextBox; currentOperation = operation; currentMessage = message; currentHeader = header; this.headerElements = headerElements; this.headerMessages = new List<Message>(); if(addedMessages != null) { foreach(Message impHeader in addedMessages) { this.headerMessages.Add(impHeader); } } this.currentRemoveButton = removeButton; this.showDialog = true; // Attach the event handlers. currentCheckBox.CheckedChanged += new EventHandler(CheckBox_CheckedChanged); currentComboBox.SelectedIndexChanged += new EventHandler(ComboBox_SelectedIndexChanged); currentMessageNameTextBox.LostFocus += new EventHandler(TextBox_FocusOver); currentRemoveButton.Click += new EventHandler(this.RemoveLink_Click); }
/// <summary> /// Imports the message headers for a specified message from an existing WSDL. /// <see cref="InterfaceContract"/>. /// </summary> /// <param name="op">Reference to the <see cref="Operation"/>, <see cref="Message"/> msg belongs to.</param> /// <param name="msg">Reference to the <see cref="Message"/>, headers belong to.</param> /// <param name="headersCombo">Reference to the combo box which contains the headers.</param> /// <param name="hasHeaders">Reference to the check box which indicates whether the custom headers are added or not.</param> /// <param name="outMessage">Indicates whether the current message is input or output.</param> /// <returns>A list of messages with the added header messages.</returns> private List<Message> ImportMessageHeaders(Operation op, Message msg, ComboBox headersCombo, CheckBox hasHeaders, bool outMessage) { // Read the message headers from the old operations collection if available. List<Message> addedHeaderMessages = null; if (oldOperations.Count > 0) { addedHeaderMessages = ImportMessageHeaders(oldOperations, op, msg, headersCombo, hasHeaders, outMessage); if (addedHeaderMessages != null) { return addedHeaderMessages; } } else { // Read the message headers from the imported contract. if (importedContract != null) { addedHeaderMessages = ImportMessageHeaders(importedContract.Operations, op, msg, headersCombo, hasHeaders, outMessage); if (addedHeaderMessages != null) { return addedHeaderMessages; } } } return addedHeaderMessages; }
/// <summary> /// Imports the message headers for a specified message from an existing WSDL. /// <see cref="InterfaceContract"/>. /// </summary> /// <param name="ops">Reference to the <see cref="OperationsCollection"/> to search for the <see cref="Operation"/>, which <see cref="Message"/> msg belongs to.</param> /// <param name="op">Reference to the <see cref="Operation"/>, <see cref="Message"/> msg belongs to.</param> /// <param name="msg">Reference to the <see cref="Message"/>, headers belong to.</param> /// <param name="headersCombo">Reference to the combo box which contains the headers.</param> /// <param name="hasHeaders">Reference to the check box which indicates whether the custom headers are added or not.</param> /// <param name="outMessage">Indicates whether the current message is input or output.</param> /// <returns>A list of messages with the added header messages.</returns> private List<Message> ImportMessageHeaders(List<Operation> ops, Operation op, Message msg, ComboBox headersCombo, CheckBox hasHeaders, bool outMessage) { List<Message> addedHeaderMessages = null; foreach (Operation importedOp in ops) { if (importedOp.Name == op.Name) { Message importedMsg = null; if (!outMessage) { importedMsg = importedOp.Input; } else { importedMsg = importedOp.Output; } // Check for the headers. if (importedMsg != null && importedMsg.HeadersCollection.Count > 0) { addedHeaderMessages = new List<Message>(); hasHeaders.Checked = true; // Enable headers check box. headersCombo.Enabled = true; // Enable the headers combo box. // Add the headers to current message's headers collection. foreach (MessageHeader header in importedMsg.HeadersCollection) { // Find and add the header message to the operation. foreach (Message headerMsg in importedOp.MessagesCollection) { if (headerMsg.Name == header.Message) { msg.HeadersCollection.Add(header); op.MessagesCollection.Add(headerMsg); addedHeaderMessages.Add(headerMsg); // Finally add the header details to the combo box. headersCombo.Items.Insert(headersCombo.Items.Count - 1, headerMsg.Element.ElementName); } } } break; } } } return addedHeaderMessages; }
private TextBox SetupOutputMessageDynamicControls(int opIndex, Message outMessage, out Label outMessageParameterLabel, out CheckBox outMessageNameCheckBox, out TextBox outMessageNameTextBox, out ComboBox outMessageParamsCombo) { TextBox outDocTextBox = new TextBox(); outDocTextBox.Location = new Point(8, 165); outDocTextBox.Multiline = true; outDocTextBox.Name = "outDocTextBox" + opIndex; outDocTextBox.Size = new Size(135, 0); outDocTextBox.DataBindings.Add("Text", outMessage, "Documentation"); outDocTextBox.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; outMessageParameterLabel = new Label(); outMessageParameterLabel.Location = new Point(6, 5); outMessageParameterLabel.Name = "outMessageParameterLabel" + opIndex; outMessageParameterLabel.Size = new Size(55, 33); outMessageParameterLabel.Text = "Message body:"; outMessageNameCheckBox = new CheckBox(); outMessageNameCheckBox.Location = new Point(9, 44); outMessageNameCheckBox.Name = "outMessageNameCheckBox" + opIndex; outMessageNameCheckBox.Text = "Message name (optional)"; outMessageNameCheckBox.Size = new Size(220, 25); outMessageNameTextBox = new TextBox(); outMessageNameTextBox.Location = new Point(8, 67); outMessageNameTextBox.Name = "outMessageNameTextBox" + opIndex; outMessageNameTextBox.Size = new Size(142, 20); outMessageNameTextBox.Enabled = false; outMessageNameTextBox.Text = outMessage.Name; outMessageNameTextBox.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; outMessageParamsCombo = new ComboBox(); outMessageParamsCombo.DropDownStyle = ComboBoxStyle.DropDownList; outMessageParamsCombo.Location = new Point(65, 5); outMessageParamsCombo.Name = "outMessageParamsCombo" + opIndex; outMessageParamsCombo.Size = new Size(80, 21); outMessageParamsCombo.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; // Fill the combo box with the Message values. foreach (SchemaElement element in serviceInterfaceContract.MessageSchemas) { outMessageParamsCombo.Items.Add(element.ElementName); } outMessageParamsCombo.SelectedIndex = 0; return outDocTextBox; }
private void CreateOutputPane(Operation operation, int opIndex, TextBox opDocTextBox, Message outMessage, PropertyPane propPaneOutMsg, string originalOperationName, MessageHeader outHeader) { Label outMessageParameterLabel; CheckBox outMessageNameCheckBox; TextBox outMessageNameTextBox; ComboBox outMessageParamsCombo; TextBox outDocTextBox = SetupOutputMessageDynamicControls(opIndex, outMessage, out outMessageParameterLabel, out outMessageNameCheckBox, out outMessageNameTextBox, out outMessageParamsCombo); operation.Output = outMessage; // Import the parameters from an existing WSDL file for round tripping. ImportMessageParameter(operation, true, outMessageParamsCombo, outMessageNameCheckBox, outMessageNameTextBox, propPaneOutMsg, opDocTextBox, outDocTextBox, originalOperationName); // Attach the dynamic combo box event handler. outMessageParamsCombo.SelectedIndexChanged += new EventHandler(DynamicComboBox_SelectedIndexChanged); CheckBox outMessageHeaderCheckBox = CreateOutMessageHeaderCheckBox(opIndex); ComboBox outMessageHeaderCombo = CreateOutMessageHeaderCombo(opIndex); // Import headers from an existing WSDL file for round tripping. List<Message> addedOutHeaderMsgs = ImportMessageHeaders(operation, outMessage, outMessageHeaderCombo, outMessageHeaderCheckBox, true); // Attach the dynamic combo box event handler. outMessageHeaderCombo.SelectedIndexChanged += new EventHandler(DynamicComboBox_SelectedIndexChanged); LinkLabel outRemoveHeaderLink = CreateOutRemoveHeaderLink(addedOutHeaderMsgs); // outRemoveHeaderLink.Anchor = AnchorStyles.Right; // Initialize the dynamic control controllers. MessagePaneLabelController mplcOut = new MessagePaneLabelController(outMessageNameTextBox, propPaneOutMsg); MessageNameTextBoxController mntbcOut = new MessageNameTextBoxController(outMessageNameTextBox, outMessageNameCheckBox, outMessage, propPaneOutMsg); OutHeaderComboBoxController hcbcOut = new OutHeaderComboBoxController(outMessageHeaderCombo, outMessageHeaderCheckBox, outMessageNameTextBox, operation, outMessage, outHeader, serviceInterfaceContract.HeaderSchemas, outRemoveHeaderLink, addedOutHeaderMsgs); MessageDocumentationTextBoxController outdtbc = new MessageDocumentationTextBoxController(outDocTextBox, outMessage); Label outDocLabel = CreateOutDocLabel(opIndex); // Finally add the generated controls to the container. propPaneOutMsg.Controls.Add(outDocTextBox); propPaneOutMsg.Controls.Add(outDocLabel); propPaneOutMsg.Controls.Add(outMessageParameterLabel); propPaneOutMsg.Controls.Add(outMessageNameTextBox); propPaneOutMsg.Controls.Add(outMessageParameterLabel); propPaneOutMsg.Controls.Add(outMessageParamsCombo); propPaneOutMsg.Controls.Add(outMessageNameCheckBox); propPaneOutMsg.Controls.Add(outMessageHeaderCombo); propPaneOutMsg.Controls.Add(outMessageHeaderCheckBox); propPaneOutMsg.Controls.Add(outRemoveHeaderLink); }
private Message AddOutputMessage(Operation operation, out string outputMessageName) { Message outMessage = new Message(); outMessage.Name = operation.Name + "Out"; outMessage.Documentation = ""; outMessage.Element = serviceInterfaceContract.MessageSchemas[0]; if (!operation.MessagesCollection.Contains(outMessage)) { operation.MessagesCollection.Add(outMessage); } outputMessageName = outMessage.Name; return outMessage; }
private string CreateInputPane(string opName, Operation operation, string inputMessageName, Message inMessage, int opIndex, TextBox opDocTextBox, PropertyPane propPaneInMsg, MessageHeader inHeader) { Label inMessageParameterLabel; CheckBox inMessageNameCheckBox; TextBox inMessageNameTextBox; ComboBox inMessageParamsCombo; TextBox inDocTextBox = SetupInputMessageDynamicControls(inputMessageName, opIndex, out inMessageParameterLabel, out inMessageNameCheckBox, out inMessageNameTextBox, out inMessageParamsCombo); // Import the parameters from WSDL file for round tripping. string originalOperationName = ""; if (opName != null) { originalOperationName = opName; } ImportMessageParameter(operation, false, inMessageParamsCombo, inMessageNameCheckBox, inMessageNameTextBox, propPaneInMsg, opDocTextBox, inDocTextBox, originalOperationName); // Attach the dynamic combo box event handler. inMessageParamsCombo.SelectedIndexChanged += new EventHandler(DynamicComboBox_SelectedIndexChanged); CheckBox inMessageHeaderCheckBox = CreateInMessageHeaderCheckBox(opIndex); ComboBox inMessageHeaderCombo = CreateInMessageHeaderCombo(opIndex); // Import headers from WSDL file for round tripping. List<Message> addedInHeaderMsgs = ImportMessageHeaders(operation, inMessage,inMessageHeaderCombo, inMessageHeaderCheckBox, false); // Attach the dynamic combo box event handler. inMessageHeaderCombo.SelectedIndexChanged += new EventHandler(DynamicComboBox_SelectedIndexChanged); LinkLabel inRemoveHeaderLink = CreateInRemoveHeaderLink(addedInHeaderMsgs); // inRemoveHeaderLink.Anchor = AnchorStyles.Right; // Initialize the dynamic control controllers. MessagePaneLabelController mplcIn = new MessagePaneLabelController(inMessageNameTextBox, propPaneInMsg); MessageNameTextBoxController mntbcIn = new MessageNameTextBoxController(inMessageNameTextBox, inMessageNameCheckBox, inMessage, propPaneInMsg); InHeaderComboBoxController hcbcIn = new InHeaderComboBoxController(inMessageHeaderCombo, inMessageHeaderCheckBox, inMessageNameTextBox, operation, inMessage, inHeader, serviceInterfaceContract.HeaderSchemas, inRemoveHeaderLink, addedInHeaderMsgs); OperationDocumentationTextBoxController odtbc = new OperationDocumentationTextBoxController(opDocTextBox, operation); MessageDocumentationTextBoxController mdtbc = new MessageDocumentationTextBoxController(inDocTextBox, inMessage); Label inDocLabel = CreateInDocLabel(opIndex); // Finally add the controls to the container. propPaneInMsg.Controls.Add(inDocTextBox); propPaneInMsg.Controls.Add(inDocLabel); propPaneInMsg.Controls.Add(inMessageParameterLabel); propPaneInMsg.Controls.Add(inMessageNameTextBox); propPaneInMsg.Controls.Add(inMessageParameterLabel); propPaneInMsg.Controls.Add(inMessageParamsCombo); propPaneInMsg.Controls.Add(inMessageNameCheckBox); propPaneInMsg.Controls.Add(inMessageHeaderCombo); propPaneInMsg.Controls.Add(inMessageHeaderCheckBox); propPaneInMsg.Controls.Add(inRemoveHeaderLink); return originalOperationName; }
private Message AddInputMessage(Operation operation, out string inputMessageName) { Message inMessage = new Message(); inMessage.Name = operation.Name + "In"; inMessage.Documentation = ""; //TODO:(SB): Is this default assignment wise? inMessage.Element = serviceInterfaceContract.MessageSchemas[0]; //check if the operation already has this as we dont want duplicates if (!operation.MessagesCollection.Contains(inMessage)) { operation.MessagesCollection.Add(inMessage); } inputMessageName = inMessage.Name; return inMessage; }