Represents the content of the Message headers exchanged by the XML web service.
        /// <summary>
        /// Inserts a <see cref="MessageHeader"/> element into the
        /// <see cref="MessageHeadersCollection"/> at the specified index.
        /// </summary>
        /// <param name="index">The zero-based index at which <paramref name="value"/>
        /// should be inserted.</param>
        /// <param name="value">The <see cref="MessageHeader"/> object
        /// to insert into the <see cref="MessageHeadersCollection"/>.
        /// This argument can be a null reference.
        /// </param>
        /// <exception cref="ArgumentOutOfRangeException">
        /// <para><paramref name="index"/> is less than zero.</para>
        /// <para>-or-</para>
        /// <para><paramref name="index"/> is greater than <see cref="Count"/>.</para>
        /// </exception>
        /// <exception cref="NotSupportedException">
        /// <para>The <see cref="MessageHeadersCollection"/> is read-only.</para>
        /// <para>-or-</para>
        /// <para>The <b>MessageHeaders</b> has a fixed size.</para>
        /// <para>-or-</para>
        /// <para>The <b>MessageHeaders</b> already contains the specified
        /// <paramref name="value"/>, and the <b>MessageHeaders</b>
        /// ensures that all elements are unique.</para></exception>
        /// <remarks>Please refer to <see cref="ArrayList.Insert"/> for details.</remarks>

        public virtual void Insert(int index, MessageHeader value) {
            if (index < 0)
                throw new ArgumentOutOfRangeException("index",
                    index, "Argument cannot be negative.");

            if (index > this._count)
                throw new ArgumentOutOfRangeException("index",
                    index, "Argument cannot exceed Count.");

            if (this._count == this._array.Length)
                EnsureCapacity(this._count + 1);

            ++this._version;
            if (index < this._count)
                Array.Copy(this._array, index,
                    this._array, index + 1, this._count - index);

            this._array[index] = value;
            ++this._count;
        }
        /// <summary>
        /// Copies the entire <see cref="MessageHeadersCollection"/> to a one-dimensional <see cref="Array"/>
        /// of <see cref="MessageHeader"/> 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="MessageHeader"/> elements copied from the <see cref="MessageHeadersCollection"/>.
        /// 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="MessageHeadersCollection"/> 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(MessageHeader[] array, int arrayIndex) {
            CheckTargetArray(array, arrayIndex);
            Array.Copy(this._array, 0, array, arrayIndex, this._count);
        }
Exemplo n.º 3
0
            /// <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 the elements of a <see cref="MessageHeader"/> array
        /// to the end of the <see cref="MessageHeadersCollection"/>.
        /// </summary>
        /// <param name="array">An <see cref="Array"/> of <see cref="MessageHeader"/> elements
        /// that should be added to the end of the <see cref="MessageHeadersCollection"/>.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="array"/> is a null reference.</exception>
        /// <exception cref="NotSupportedException">
        /// <para>The <see cref="MessageHeadersCollection"/> is read-only.</para>
        /// <para>-or-</para>
        /// <para>The <b>MessageHeaders</b> has a fixed size.</para>
        /// <para>-or-</para>
        /// <para>The <b>MessageHeaders</b> already contains one or more elements
        /// in the specified <paramref name="array"/>, and the <b>MessageHeaders</b>
        /// ensures that all elements are unique.</para></exception>
        /// <remarks>Please refer to <see cref="ArrayList.AddRange"/> for details.</remarks>

        public virtual void AddRange(MessageHeader[] 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>
        /// Determines whether the <see cref="MessageHeadersCollection"/>
        /// contains the specified <see cref="MessageHeader"/> element.
        /// </summary>
        /// <param name="value">The <see cref="MessageHeader"/> object
        /// to locate in the <see cref="MessageHeadersCollection"/>.
        /// This argument can be a null reference.
        /// </param>
        /// <returns><c>true</c> if <paramref name="value"/> is found in the
        /// <see cref="MessageHeadersCollection"/>; otherwise, <c>false</c>.</returns>
        /// <remarks>Please refer to <see cref="ArrayList.Contains"/> for details.</remarks>

        public bool Contains(MessageHeader value) {
            return (IndexOf(value) >= 0);
        }
 private void CheckUnique(MessageHeader value) {
     if (IndexOf(value) >= 0)
         throw new NotSupportedException(
             "Unique collections cannot contain duplicate elements.");
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="MessageHeadersCollection"/> class
        /// that contains elements copied from the specified <see cref="MessageHeader"/>
        /// 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="MessageHeader"/>
        /// 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 MessageHeadersCollection(MessageHeader[] array) {
            if (array == null)
                throw new ArgumentNullException("array");

            this._array = new MessageHeader[array.Length];
            AddRange(array);
        }
 public override void AddRange(MessageHeader[] array) {
     lock (this._root) this._collection.AddRange(array);
 }
 public override void Insert(int index, MessageHeader value) {
     lock (this._root) this._collection.Insert(index, value);
 }
 public override void Remove(MessageHeader value) {
     throw new NotSupportedException(
         "Read-only collections cannot be modified.");
 }
 public override int Add(MessageHeader value) {
     lock (this._root) return this._collection.Add(value);
 }
 public override void AddRange(MessageHeader[] array) {
     throw new NotSupportedException(
         "Read-only collections cannot be modified.");
 }
        /// <summary>
        /// Copies the elements of the <see cref="MessageHeadersCollection"/> to a new
        /// <see cref="Array"/> of <see cref="MessageHeader"/> elements.
        /// </summary>
        /// <returns>A one-dimensional <see cref="Array"/> of <see cref="MessageHeader"/>
        /// elements containing copies of the elements of the <see cref="MessageHeadersCollection"/>.</returns>
        /// <remarks>Please refer to <see cref="ArrayList.ToArray"/> for details.</remarks>

        public virtual MessageHeader[] ToArray() {
            MessageHeader[] array = new MessageHeader[this._count];
            Array.Copy(this._array, array, this._count);
            return array;
        }
        /// <summary>
        /// Removes the first occurrence of the specified <see cref="MessageHeader"/>
        /// from the <see cref="MessageHeadersCollection"/>.
        /// </summary>
        /// <param name="value">The <see cref="MessageHeader"/> object
        /// to remove from the <see cref="MessageHeadersCollection"/>.
        /// This argument can be a null reference.
        /// </param>
        /// <exception cref="NotSupportedException">
        /// <para>The <see cref="MessageHeadersCollection"/> is read-only.</para>
        /// <para>-or-</para>
        /// <para>The <b>MessageHeaders</b> has a fixed size.</para></exception>
        /// <remarks>Please refer to <see cref="ArrayList.Remove"/> for details.</remarks>

        public virtual void Remove(MessageHeader value) {
            int index = IndexOf(value);
            if (index >= 0) RemoveAt(index);
        }
 public override void Insert(int index, MessageHeader value) {
     CheckUnique(value);
     this._collection.Insert(index, value);
 }
 public override void Remove(MessageHeader value) {
     lock (this._root) this._collection.Remove(value);
 }
 public override void Remove(MessageHeader value) {
     this._collection.Remove(value);
 }
 public override int Add(MessageHeader value) {
     CheckUnique(value);
     return this._collection.Add(value);
 }
 private void CheckUnique(int index, MessageHeader value) {
     int existing = IndexOf(value);
     if (existing >= 0 && existing != index)
         throw new NotSupportedException(
             "Unique collections cannot contain duplicate elements.");
 }
 public override void AddRange(MessageHeader[] array) {
     foreach (MessageHeader value in array)
         CheckUnique(value);
 
     this._collection.AddRange(array);
 }
        /// <summary>
        /// Adds a <see cref="MessageHeader"/> to the end of the <see cref="MessageHeadersCollection"/>.
        /// </summary>
        /// <param name="value">The <see cref="MessageHeader"/> object
        /// to be added to the end of the <see cref="MessageHeadersCollection"/>.
        /// This argument can be a null reference.
        /// </param>
        /// <returns>The <see cref="MessageHeadersCollection"/> index at which the
        /// <paramref name="value"/> has been added.</returns>
        /// <exception cref="NotSupportedException">
        /// <para>The <see cref="MessageHeadersCollection"/> is read-only.</para>
        /// <para>-or-</para>
        /// <para>The <b>MessageHeaders</b> has a fixed size.</para>
        /// <para>-or-</para>
        /// <para>The <b>MessageHeaders</b> already contains the specified
        /// <paramref name="value"/>, and the <b>MessageHeaders</b>
        /// ensures that all elements are unique.</para></exception>
        /// <remarks>Please refer to <see cref="ArrayList.Add"/> for details.</remarks>

        public virtual int Add(MessageHeader value) {
            if (this._count == this._array.Length)
                EnsureCapacity(this._count + 1);

            ++this._version;
            this._array[this._count] = value;
            return this._count++;
        }
 public override int BinarySearch(MessageHeader value) {
     return this._collection.BinarySearch(value);
 }
        /// <summary>
        /// Searches the entire sorted <see cref="MessageHeadersCollection"/> for an
        /// <see cref="MessageHeader"/> element using the default comparer
        /// and returns the zero-based index of the element.
        /// </summary>
        /// <param name="value">The <see cref="MessageHeader"/> object
        /// to locate in the <see cref="MessageHeadersCollection"/>.
        /// This argument can be a null reference.
        /// </param>
        /// <returns>The zero-based index of <paramref name="value"/> in the sorted
        /// <see cref="MessageHeadersCollection"/>, 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="MessageHeadersCollection"/>
        /// implement the <see cref="IComparable"/> interface.</exception>
        /// <remarks>Please refer to <see cref="ArrayList.BinarySearch"/> for details.</remarks>

        public virtual int BinarySearch(MessageHeader value) {
            return Array.BinarySearch(this._array, 0, this._count, value);
        }
 public override void CopyTo(MessageHeader[] array) {
     this._collection.CopyTo(array);
 }
        /// <overloads>
        /// Copies the <see cref="MessageHeadersCollection"/> or a portion of it to a one-dimensional array.
        /// </overloads>
        /// <summary>
        /// Copies the entire <see cref="MessageHeadersCollection"/> to a one-dimensional <see cref="Array"/>
        /// of <see cref="MessageHeader"/> 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="MessageHeader"/> elements copied from the <see cref="MessageHeadersCollection"/>.
        /// 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="MessageHeadersCollection"/> 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(MessageHeader[] array) {
            CheckTargetArray(array, 0);
            Array.Copy(this._array, array, this._count);
        }
 public override void CopyTo(MessageHeader[] array, int arrayIndex) {
     this._collection.CopyTo(array, arrayIndex);
 }
Exemplo n.º 27
0
        /// <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 int IndexOf(MessageHeader value) {
     return this._collection.IndexOf(value);
 }
Exemplo n.º 29
0
            /// <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>
        /// Returns the zero-based index of the first occurrence of the specified
        /// <see cref="MessageHeader"/> in the <see cref="MessageHeadersCollection"/>.
        /// </summary>
        /// <param name="value">The <see cref="MessageHeader"/> object
        /// to locate in the <see cref="MessageHeadersCollection"/>.
        /// This argument can be a null reference.
        /// </param>
        /// <returns>
        /// The zero-based index of the first occurrence of <paramref name="value"/>
        /// in the <see cref="MessageHeadersCollection"/>, if found; otherwise, -1.
        /// </returns>
        /// <remarks>Please refer to <see cref="ArrayList.IndexOf"/> for details.</remarks>

        public virtual int IndexOf(MessageHeader value) {
            return Array.IndexOf(this._array, value, 0, this._count);
        }