public override void Insert(int index, Message value) { lock (this._root) this._collection.Insert(index, value); }
/// <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> /// 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>An instance of <see cref="MessagesCollection"/> class with the added header messages.</returns> private MessagesCollection ImportMessageHeaders(OperationsCollection ops, Operation op, Message msg, ComboBox headersCombo, CheckBox hasHeaders, bool outMessage) { MessagesCollection 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 MessagesCollection(); 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 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; }
/// <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); }
/// <overloads> /// Copies the <see cref="MessagesCollection"/> or a portion of it to a one-dimensional array. /// </overloads> /// <summary> /// Copies the entire <see cref="MessagesCollection"/> to a one-dimensional <see cref="Array"/> /// of <see cref="Message"/> elements, starting at the beginning of the target array. /// </summary> /// <param name="array">The one-dimensional <see cref="Array"/> that is the destination of the /// <see cref="Message"/> elements copied from the <see cref="MessagesCollection"/>. /// The <b>Array</b> must have zero-based indexing.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="array"/> is a null reference.</exception> /// <exception cref="ArgumentException"> /// The number of elements in the source <see cref="MessagesCollection"/> is greater /// than the available space in the destination <paramref name="array"/>.</exception> /// <remarks>Please refer to <see cref="ArrayList.CopyTo"/> for details.</remarks> public virtual void CopyTo(Message[] array) { CheckTargetArray(array, 0); Array.Copy(this._array, array, this._count); }
/// <summary> /// Prepares the dynamic controls for the operations-message parameters mapping UI. /// </summary> private void SetupOperationsMessagesPanes() { int i = 0; ((ISupportInitialize)ptvServiceOperations).BeginInit(); ptvServiceOperations.SuspendLayout(); // Clear the existing items. serviceInterfaceContract.OperationsCollection.Clear(); ptvServiceOperations.PaneNodes.Clear(); foreach (ListViewItem lvi in operationsListView.Items) { bool found = false; // Check whether the operation already has a property pane or not. foreach (PaneNode proPane in ptvServiceOperations.PaneNodes) { if (lvi.Text == (string)proPane.PropertyPane.Tag) { found = true; break; } } if (found) { continue; } Operation operation = new Operation(); operation.Name = lvi.Text; string mepValue = lvi.SubItems[1].Text; if (mepValue == "One-Way") operation.Mep = Mep.OneWay; else operation.Mep = Mep.RequestResponse; operation.Documentation = ""; string opName = operation.Name; string opNamePrefix = opName.Substring(0, 1); opNamePrefix = opNamePrefix.ToLower(CultureInfo.CurrentCulture); opName = opName.Substring(1, opName.Length - 1); opName = opNamePrefix + opName; Message inMessage = new Message(); inMessage.Name = opName + "In"; inMessage.Documentation = ""; inMessage.Element = messageSchemas[0]; operation.MessagesCollection.Add(inMessage); MessageHeader inHeader = new MessageHeader(); inHeader.Name = inMessage.Name + "Header"; inHeader.Message = inMessage.Name + "Header"; serviceInterfaceContract.OperationsCollection.Add(operation); PropertyPane propPaneOp = new PropertyPane(); propPaneOp.Name = "propPaneOp" + i; propPaneOp.Text = "Operation " + operation.Name; propPaneOp.Tag = operation.Name; // Setup dynamic GUI controls for the pane - Operation LinkLabel addFaultMessage = new LinkLabel(); addFaultMessage.Text = "Add Fault Message"; addFaultMessage.Location = new Point(6, 5); addFaultMessage.Click += addFaultMessage_Clicked; propPaneOp.Controls.Add(addFaultMessage); ptvServiceOperations.PaneNodes.Add(propPaneOp); PropertyPane propPaneInMsg = new PropertyPane(); propPaneInMsg.Name = "propPaneInMsg" + i; propPaneInMsg.Text = "Message " + inMessage.Name; propPaneOp.PaneNodes.Add(propPaneInMsg); propPaneOp.PaneNode.Expanded = true; PropertyPane propPaneOutMsg = null; Message outMessage = null; MessageHeader outHeader = null; if (operation.Mep == Mep.RequestResponse) { outMessage = new Message(); outMessage.Name = opName + "Out"; outMessage.Documentation = ""; outMessage.Element = messageSchemas[0]; operation.MessagesCollection.Add(outMessage); outHeader = new MessageHeader(); outHeader.Name = outMessage.Name + "Header"; outHeader.Message = outMessage.Name + "Header"; propPaneOutMsg = new PropertyPane(); propPaneOutMsg.Name = "propPaneOutMsg" + i; propPaneOutMsg.Text = "Message " + outMessage.Name; propPaneOp.PaneNodes.Add(propPaneOutMsg); propPaneOp.PaneNode.Expanded = true; } // Setup dynamic GUI controls for the pane - Operation TextBox opDocTextBox = new TextBox(); opDocTextBox.Location = new Point(8, 148); opDocTextBox.Multiline = true; opDocTextBox.Name = "outDocTextBox" + i; opDocTextBox.Size = new Size(135, 0); opDocTextBox.DataBindings.Add("Text", operation, "Documentation"); opDocTextBox.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; Label opDocLabel = new Label(); opDocLabel.Location = new Point(8, 128); opDocLabel.Name = "outDocLabel" + i; opDocLabel.Size = new Size(88, 23); opDocLabel.Text = "Documentation:"; propPaneOp.Controls.Add(opDocTextBox); propPaneOp.Controls.Add(opDocLabel); // Setup dynamic GUI controls for the pane - InMessage TextBox inDocTextBox = new TextBox(); inDocTextBox.Location = new Point(8, 168); inDocTextBox.Multiline = true; inDocTextBox.Name = "inDocTextBox" + i; inDocTextBox.Size = new Size(135, 0); inDocTextBox.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; Label inMessageParameterLabel = new Label(); inMessageParameterLabel.Location = new Point(6, 5); inMessageParameterLabel.Name = "inMessageParameterLabel" + i; inMessageParameterLabel.Size = new Size(55, 33); inMessageParameterLabel.Text = "Message body:"; CheckBox inMessageNameCheckBox = new CheckBox(); inMessageNameCheckBox.Location = new Point(9, 44); inMessageNameCheckBox.Name = "inMessageNameCheckBox" + i; inMessageNameCheckBox.Text = "Message name (optional)"; inMessageNameCheckBox.Size = new Size(220, 25); TextBox inMessageNameTextBox = new TextBox(); inMessageNameTextBox.Location = new Point(8, 69); inMessageNameTextBox.Name = "inMessageNameTextBox" + i; inMessageNameTextBox.Size = new Size(142, 20); inMessageNameTextBox.Enabled = false; inMessageNameTextBox.Text = inMessage.Name; inMessageNameTextBox.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; ComboBox inMessageParamsCombo = new ComboBox(); inMessageParamsCombo.DropDownStyle = ComboBoxStyle.DropDownList; inMessageParamsCombo.Location = new Point(65, 5); inMessageParamsCombo.Name = "inMessageParamsCombo" + i; inMessageParamsCombo.Size = new Size(80, 21); inMessageParamsCombo.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; // Fill the combo box with the Message values. foreach (SchemaElement element in this.messageSchemas) { inMessageParamsCombo.Items.Add(element.ElementName); } inMessageParamsCombo.SelectedIndex = 0; operation.Input = inMessage; // Import the parameters from WSDL file for round tripping. string originalOperationName = ""; if (lvi.Tag != null) { originalOperationName = lvi.Tag.ToString(); } 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 = new CheckBox(); inMessageHeaderCheckBox.Location = new Point(9, 95); inMessageHeaderCheckBox.Name = "inMessageHeaderCheckBox" + i; inMessageHeaderCheckBox.Text = "Message headers (optional)"; inMessageHeaderCheckBox.Size = new Size(181, 25); ComboBox inMessageHeaderCombo = new ComboBox(); inMessageHeaderCombo.DropDownStyle = ComboBoxStyle.DropDownList; inMessageHeaderCombo.Location = new Point(8, 120); inMessageHeaderCombo.Enabled = false; inMessageHeaderCombo.Name = "inMessageHeaderCombo" + i; inMessageHeaderCombo.Size = new Size(100, 21); inMessageHeaderCombo.Items.Add("<New...>"); inMessageHeaderCombo.SelectedIndex = 0; inMessageHeaderCombo.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; // Import headers from WSDL file for round tripping. MessagesCollection addedInHeaderMsgs = ImportMessageHeaders(operation, inMessage, inMessageHeaderCombo, inMessageHeaderCheckBox, false); // Attach the dynamic combo box event handler. inMessageHeaderCombo.SelectedIndexChanged += new EventHandler(DynamicComboBox_SelectedIndexChanged); LinkLabel inRemoveHeaderLink = new LinkLabel(); inRemoveHeaderLink.Text = "Remove"; inRemoveHeaderLink.Location = new Point(193, 95); inRemoveHeaderLink.Size = new Size(64, 25); inRemoveHeaderLink.TextAlign = ContentAlignment.MiddleRight; inRemoveHeaderLink.Visible = (addedInHeaderMsgs != null); // 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, this.headerSchemas, inRemoveHeaderLink, addedInHeaderMsgs); OperationDocumentationTextBoxController odtbc = new OperationDocumentationTextBoxController(opDocTextBox, operation); MessageDocumentationTextBoxController mdtbc = new MessageDocumentationTextBoxController(inDocTextBox, inMessage); Label inDocLabel = new Label(); inDocLabel.Location = new Point(8, 149); inDocLabel.Name = "inDocLabel" + i; inDocLabel.Size = new Size(88, 23); inDocLabel.Text = "Documentation:"; // 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); // Setup dynamic GUI controls for the pane - OutMessage if (operation.Mep == Mep.RequestResponse) { TextBox outDocTextBox = new TextBox(); outDocTextBox.Location = new Point(8, 165); outDocTextBox.Multiline = true; outDocTextBox.Name = "outDocTextBox" + i; outDocTextBox.Size = new Size(135, 0); outDocTextBox.DataBindings.Add("Text", outMessage, "Documentation"); outDocTextBox.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; Label outMessageParameterLabel = new Label(); outMessageParameterLabel.Location = new Point(6, 5); outMessageParameterLabel.Name = "outMessageParameterLabel" + i; outMessageParameterLabel.Size = new Size(55, 33); outMessageParameterLabel.Text = "Message body:"; CheckBox outMessageNameCheckBox = new CheckBox(); outMessageNameCheckBox.Location = new Point(9, 44); outMessageNameCheckBox.Name = "outMessageNameCheckBox" + i; outMessageNameCheckBox.Text = "Message name (optional)"; outMessageNameCheckBox.Size = new Size(220, 25); TextBox outMessageNameTextBox = new TextBox(); outMessageNameTextBox.Location = new Point(8, 69); outMessageNameTextBox.Name = "outMessageNameTextBox" + i; outMessageNameTextBox.Size = new Size(142, 20); outMessageNameTextBox.Enabled = false; outMessageNameTextBox.Text = outMessage.Name; outMessageNameTextBox.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; ComboBox outMessageParamsCombo = new ComboBox(); outMessageParamsCombo.DropDownStyle = ComboBoxStyle.DropDownList; outMessageParamsCombo.Location = new Point(65, 5); outMessageParamsCombo.Name = "outMessageParamsCombo" + i; 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 this.messageSchemas) { outMessageParamsCombo.Items.Add(element.ElementName); } outMessageParamsCombo.SelectedIndex = 0; 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 = new CheckBox(); outMessageHeaderCheckBox.Location = new Point(9, 95); outMessageHeaderCheckBox.Name = "outMessageHeaderCheckBox" + i; outMessageHeaderCheckBox.Text = "Message headers (optional)"; outMessageHeaderCheckBox.Size = new Size(181, 25); ComboBox outMessageHeaderCombo = new ComboBox(); outMessageHeaderCombo.DropDownStyle = ComboBoxStyle.DropDownList; outMessageHeaderCombo.Location = new Point(8, 120); outMessageHeaderCombo.Enabled = false; outMessageHeaderCombo.Name = "outMessageHeaderCombo" + i; outMessageHeaderCombo.Size = new Size(100, 21); outMessageHeaderCombo.Items.Add("<New...>"); outMessageHeaderCombo.SelectedIndex = 0; outMessageHeaderCombo.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; // Import headers from an existing WSDL file for round tripping. MessagesCollection addedOutHeaderMsgs = ImportMessageHeaders(operation, outMessage, outMessageHeaderCombo, outMessageHeaderCheckBox, true); // Attach the dynamic combo box event handler. outMessageHeaderCombo.SelectedIndexChanged += new EventHandler(DynamicComboBox_SelectedIndexChanged); LinkLabel outRemoveHeaderLink = new LinkLabel(); outRemoveHeaderLink.Text = "Remove"; outRemoveHeaderLink.Location = new Point(193, 95); outRemoveHeaderLink.Size = new Size(64, 25); outRemoveHeaderLink.TextAlign = ContentAlignment.MiddleRight; outRemoveHeaderLink.Visible = (addedOutHeaderMsgs != null); // 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, headerSchemas, outRemoveHeaderLink, addedOutHeaderMsgs); MessageDocumentationTextBoxController outdtbc = new MessageDocumentationTextBoxController(outDocTextBox, outMessage); Label outDocLabel = new Label(); outDocLabel.Location = new Point(8, 149); outDocLabel.Name = "outDocLabel" + i; outDocLabel.Size = new Size(88, 23); outDocLabel.Text = "Documentation:"; // 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); } ImportFaultMessages(propPaneOp.PaneNode, operation, originalOperationName); i++; } oldOperations = (OperationsCollection)serviceInterfaceContract.OperationsCollection.Clone(); ((ISupportInitialize)ptvServiceOperations).EndInit(); ptvServiceOperations.ResumeLayout(false); }
public override void CopyTo(Message[] array, int arrayIndex) { this._collection.CopyTo(array, arrayIndex); }
public override int IndexOf(Message value) { return this._collection.IndexOf(value); }
public override int BinarySearch(Message value) { return this._collection.BinarySearch(value); }
public override void CopyTo(Message[] array) { this._collection.CopyTo(array); }
public override void AddRange(Message[] array) { foreach (Message value in array) CheckUnique(value); this._collection.AddRange(array); }
public override int Add(Message value) { CheckUnique(value); return this._collection.Add(value); }
public override void Remove(Message value) { lock (this._root) this._collection.Remove(value); }
/// <summary> /// Searches the entire sorted <see cref="MessagesCollection"/> for an /// <see cref="Message"/> element using the default comparer /// and returns the zero-based index of the element. /// </summary> /// <param name="value">The <see cref="Message"/> object /// to locate in the <see cref="MessagesCollection"/>. /// This argument can be a null reference. /// </param> /// <returns>The zero-based index of <paramref name="value"/> in the sorted /// <see cref="MessagesCollection"/>, if <paramref name="value"/> is found; /// otherwise, a negative number, which is the bitwise complement of the index /// of the next element that is larger than <paramref name="value"/> or, if there /// is no larger element, the bitwise complement of <see cref="Count"/>.</returns> /// <exception cref="InvalidOperationException"> /// Neither <paramref name="value"/> nor the elements of the <see cref="MessagesCollection"/> /// implement the <see cref="IComparable"/> interface.</exception> /// <remarks>Please refer to <see cref="ArrayList.BinarySearch"/> for details.</remarks> public virtual int BinarySearch(Message value) { return Array.BinarySearch(this._array, 0, this._count, value); }
public override void Insert(int index, Message value) { CheckUnique(value); this._collection.Insert(index, value); }
/// <summary> /// Determines whether the <see cref="MessagesCollection"/> /// contains the specified <see cref="Message"/> element. /// </summary> /// <param name="value">The <see cref="Message"/> object /// to locate in the <see cref="MessagesCollection"/>. /// This argument can be a null reference. /// </param> /// <returns><c>true</c> if <paramref name="value"/> is found in the /// <see cref="MessagesCollection"/>; otherwise, <c>false</c>.</returns> /// <remarks>Please refer to <see cref="ArrayList.Contains"/> for details.</remarks> public bool Contains(Message value) { return (IndexOf(value) >= 0); }
public override void Remove(Message value) { this._collection.Remove(value); }
/// <summary> /// Copies the entire <see cref="MessagesCollection"/> to a one-dimensional <see cref="Array"/> /// of <see cref="Message"/> elements, starting at the specified index of the target array. /// </summary> /// <param name="array">The one-dimensional <see cref="Array"/> that is the destination of the /// <see cref="Message"/> elements copied from the <see cref="MessagesCollection"/>. /// The <b>Array</b> must have zero-based indexing.</param> /// <param name="arrayIndex">The zero-based index in <paramref name="array"/> /// at which copying begins.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="array"/> is a null reference.</exception> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="arrayIndex"/> is less than zero.</exception> /// <exception cref="ArgumentException"><para> /// <paramref name="arrayIndex"/> is equal to or greater than the length of <paramref name="array"/>. /// </para><para>-or-</para><para> /// The number of elements in the source <see cref="MessagesCollection"/> is greater than the /// available space from <paramref name="arrayIndex"/> to the end of the destination /// <paramref name="array"/>.</para></exception> /// <remarks>Please refer to <see cref="ArrayList.CopyTo"/> for details.</remarks> public virtual void CopyTo(Message[] array, int arrayIndex) { CheckTargetArray(array, arrayIndex); Array.Copy(this._array, 0, array, arrayIndex, this._count); }
private void CheckUnique(Message value) { if (IndexOf(value) >= 0) throw new NotSupportedException( "Unique collections cannot contain duplicate elements."); }
private void addFaultMessage_Clicked(object sender, EventArgs e) { ptvServiceOperations.SuspendLayout(); PaneNode operationNode = ptvServiceOperations.SelectedPaneNode; Operation selectedOperation = serviceInterfaceContract.OperationsCollection .Cast<Operation>() .FirstOrDefault(operation => operation.Name == (string)operationNode.PropertyPane.Tag); if (selectedOperation == null) return; string name = "Fault" + (selectedOperation.Faults.Count() + 1); Message faultMessage = new Message {Name = name, Element = new SchemaElement()}; ptvServiceOperations.SelectedPaneNode = AddFaultPropertyPane(operationNode, selectedOperation, faultMessage); ptvServiceOperations.ResumeLayout(true); }
private void CheckUnique(int index, Message value) { int existing = IndexOf(value); if (existing >= 0 && existing != index) throw new NotSupportedException( "Unique collections cannot contain duplicate elements."); }
/// <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 the <see cref="MessagesCollection"/> class /// that contains elements copied from the specified <see cref="Message"/> /// array and that has the same initial capacity as the number of elements copied. /// </summary> /// <param name="array">An <see cref="Array"/> of <see cref="Message"/> /// elements that are copied to the new collection.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="array"/> is a null reference.</exception> /// <remarks>Please refer to <see cref="ArrayList(ICollection)"/> for details.</remarks> public MessagesCollection(Message[] array) { if (array == null) throw new ArgumentNullException("array"); this._array = new Message[array.Length]; AddRange(array); }
/// <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, SchemaElements headerElements, LinkLabel removeButton, MessagesCollection addedMessages) { currentComboBox = headerComboBox; currentCheckBox = headerCheckBox; currentMessageNameTextBox = messageNameTextBox; currentOperation = operation; currentMessage = message; currentHeader = header; this.headerElements = headerElements; this.headerMessages = new MessagesCollection(); 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> /// Adds a <see cref="Message"/> to the end of the <see cref="MessagesCollection"/>. /// </summary> /// <param name="value">The <see cref="Message"/> object /// to be added to the end of the <see cref="MessagesCollection"/>. /// This argument can be a null reference. /// </param> /// <returns>The <see cref="MessagesCollection"/> index at which the /// <paramref name="value"/> has been added.</returns> /// <exception cref="NotSupportedException"> /// <para>The <see cref="MessagesCollection"/> is read-only.</para> /// <para>-or-</para> /// <para>The <b>Messages</b> has a fixed size.</para> /// <para>-or-</para> /// <para>The <b>Messages</b> already contains the specified /// <paramref name="value"/>, and the <b>Messages</b> /// ensures that all elements are unique.</para></exception> /// <remarks>Please refer to <see cref="ArrayList.Add"/> for details.</remarks> public virtual int Add(Message value) { if (this._count == this._array.Length) EnsureCapacity(this._count + 1); ++this._version; this._array[this._count] = value; return this._count++; }
/// <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>An instance of <see cref="MessagesCollection"/> class with the added header messages.</returns> private MessagesCollection ImportMessageHeaders(Operation op, Message msg, ComboBox headersCombo, CheckBox hasHeaders, bool outMessage) { // Read the message headers from the old operations collection if available. MessagesCollection 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.OperationsCollection, op, msg, headersCombo, hasHeaders, outMessage); if(addedHeaderMessages != null) { return addedHeaderMessages; } } } return addedHeaderMessages; }
/// <summary> /// Adds the elements of a <see cref="Message"/> array /// to the end of the <see cref="MessagesCollection"/>. /// </summary> /// <param name="array">An <see cref="Array"/> of <see cref="Message"/> elements /// that should be added to the end of the <see cref="MessagesCollection"/>.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="array"/> is a null reference.</exception> /// <exception cref="NotSupportedException"> /// <para>The <see cref="MessagesCollection"/> is read-only.</para> /// <para>-or-</para> /// <para>The <b>Messages</b> has a fixed size.</para> /// <para>-or-</para> /// <para>The <b>Messages</b> already contains one or more elements /// in the specified <paramref name="array"/>, and the <b>Messages</b> /// ensures that all elements are unique.</para></exception> /// <remarks>Please refer to <see cref="ArrayList.AddRange"/> for details.</remarks> public virtual void AddRange(Message[] array) { if (array == null) throw new ArgumentNullException("array"); if (array.Length == 0) return; if (this._count + array.Length > this._array.Length) EnsureCapacity(this._count + array.Length); ++this._version; Array.Copy(array, 0, this._array, this._count, array.Length); this._count += array.Length; }
/// <summary> /// Infers the operations according to the message name patterns in the message contracts. /// </summary> private void InferOperations() { // Define a hash table with list of request/response patterns. Dictionary<string, string> patterns = new Dictionary<string, string>(); patterns.Add("", "Response"); patterns.Add("Request", "Response"); patterns.Add("RequestMessage", "ResponseMessage"); SchemaElements usedElements = new SchemaElements(); // Infer two-way operations. foreach(SchemaElement melement in messageSchemas) { foreach(string requestPattern in patterns.Keys) { string operationName = ""; if(melement.ElementName.EndsWith(requestPattern)) { string responsePattern = patterns[requestPattern]; // Create the response element. SchemaElement responseElement = new SchemaElement(); if(requestPattern == "") { operationName = melement.ElementName; responseElement.ElementName = melement.ElementName + responsePattern; } else { if(melement.ElementName == requestPattern) { operationName = melement.ElementName; responseElement.ElementName = responsePattern; } else { operationName = melement.ElementName.Substring(0, melement.ElementName.LastIndexOf(requestPattern)); responseElement.ElementName = melement.ElementName.Substring(0, melement.ElementName.LastIndexOf(requestPattern)) + responsePattern; } } responseElement.ElementNamespace = melement.ElementNamespace; if(messageSchemas.Contains(responseElement)) { // Check whether the operation exists in the imported operations list. bool exists = false; if(importedContract != null) { foreach(Operation impOp in importedContract.OperationsCollection) { if(impOp.Input.Element == melement && (impOp.Output != null && impOp.Output.Element == responseElement)) { exists = true; break; } } } if(exists) { break; } // Add the operation to the list. Operation op = new Operation(); op.Name = operationName; op.Documentation = ""; op.Mep = Mep.RequestResponse; string opName = op.Name; string opNamePrefix = opName.Substring(0, 1); opNamePrefix = opNamePrefix.ToLower(CultureInfo.CurrentCulture); opName = op.Name.Substring(1, op.Name.Length - 1); opName = opNamePrefix + opName; // Add the input message. Message input = new Message(); input.Name = opName + "In"; input.Element = melement; input.Documentation = ""; op.MessagesCollection.Add(input); op.Input = input; // Add the output message. Message output = new Message(); output.Name = opName + "Out"; output.Element = responseElement; output.Documentation = ""; op.MessagesCollection.Add(output); op.Output = output; // Add the operation to the inferred operations collection. inferOperations.Add(op); // Add the operation to the list view. ListViewItem listViewItem1 = new ListViewItem(new string[] { op.Name, "Request/Response", "", ""}, -1); listViewItem1.Tag = op.Name; operationsListView.Items.AddRange( new ListViewItem[] {listViewItem1}); usedElements.Add(melement); usedElements.Add(responseElement); // Exit this loop. break; } } } } // Infer one-way operations. foreach(SchemaElement melement in messageSchemas) { foreach(string requestPattern in patterns.Keys) { string operationName = ""; if(melement.ElementName.EndsWith(requestPattern)) { if(!usedElements.Contains(melement)) { // Check whether the operation exists in the imported operations list. bool exists = false; if(importedContract != null) { foreach(Operation impOp in importedContract.OperationsCollection) { if(impOp.Input.Element == melement || (impOp.Output != null && impOp.Output.Element == melement)) { exists = true; break; } } } if(exists) { break; } // Compose the operation name. if(requestPattern == "") { operationName = melement.ElementName; } else { if(melement.ElementName == requestPattern) { operationName = melement.ElementName; } else { operationName = melement.ElementName.Substring(0, melement.ElementName.LastIndexOf(requestPattern)); } } // Add the operation to the list. Operation op = new Operation(); op.Name = operationName; op.Documentation = ""; op.Mep = Mep.OneWay; string opName = op.Name; string opNamePrefix = opName.Substring(0, 1); opNamePrefix = opNamePrefix.ToLower(CultureInfo.CurrentCulture); opName = op.Name.Substring(1, op.Name.Length - 1); opName = opNamePrefix + opName; // Add the input message. Message input = new Message(); input.Name = opName + "In"; input.Element = melement; input.Documentation = ""; op.MessagesCollection.Add(input); op.Input = input; // Add the operation to the inferred operations collection. inferOperations.Add(op); // Add the operation to the list view. ListViewItem listViewItem1 = new ListViewItem(new string[] { op.Name, "One-Way", "", ""}, -1); listViewItem1.Tag = op.Name; operationsListView.Items.AddRange( new ListViewItem[] {listViewItem1}); } // Exit this loop. break; } } } }
public override void CopyTo(Message[] array) { lock (this._root) this._collection.CopyTo(array); }