Inheritance: IOperationList, IList, ICloneable
Exemple #1
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);
        }
Exemple #2
0
 private void ImportFaultMessages(PaneNode operationNode, Operation operation, string originalOperationName, OperationsCollection operations)
 {
     foreach (Operation op in operations)
     {
         if (op.Name == operation.Name || (originalOperationName != string.Empty && op.Name == originalOperationName))
         {
             foreach (Message faultMessage in op.Faults)
             {
                 AddFaultPropertyPane(operationNode, operation, faultMessage);
             }
         }
     }
 }
        /// <overloads>
        /// Adds a range of elements to the end of the <see cref="OperationsCollection"/>.
        /// </overloads>
        /// <summary>
        /// Adds the elements of another collection to the end of the <see cref="OperationsCollection"/>.
        /// </summary>
        /// <param name="collection">The <see cref="OperationsCollection"/> whose elements
        /// should be added to the end of the current collection.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="collection"/> is a null reference.</exception>
        /// <exception cref="NotSupportedException">
        /// <para>The <see cref="OperationsCollection"/> is read-only.</para>
        /// <para>-or-</para>
        /// <para>The <b>Operations</b> has a fixed size.</para>
        /// <para>-or-</para>
        /// <para>The <b>Operations</b> already contains one or more elements
        /// in the specified <paramref name="collection"/>, and the <b>Operations</b>
        /// ensures that all elements are unique.</para></exception>
        /// <remarks>Please refer to <see cref="ArrayList.AddRange"/> for details.</remarks>

        public virtual void AddRange(OperationsCollection collection) {
            if (collection == null)
                throw new ArgumentNullException("collection");

            if (collection.Count == 0) return;
            if (this._count + collection.Count > this._array.Length)
                EnsureCapacity(this._count + collection.Count);

            ++this._version;
            Array.Copy(collection.InnerArray, 0,
                this._array, this._count, collection.Count);
            this._count += collection.Count;
        }
        /// <summary>
        /// Creates a shallow copy of the <see cref="OperationsCollection"/>.
        /// </summary>
        /// <returns>A shallow copy of the <see cref="OperationsCollection"/>.</returns>
        /// <remarks>Please refer to <see cref="ArrayList.Clone"/> for details.</remarks>

        public virtual object Clone() {
        	OperationsCollection collection = new OperationsCollection(this._count);

            Array.Copy(this._array, 0, collection._array, 0, this._count);
            collection._count = this._count;
            collection._version = this._version;

            return collection;
        }
 public override void AddRange(OperationsCollection collection) {
     foreach (Operation value in collection)
         CheckUnique(value);
 
     this._collection.AddRange(collection);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="OperationsCollection"/> class
        /// that contains elements copied from the specified collection and
        /// that has the same initial capacity as the number of elements copied.
        /// </summary>
        /// <param name="collection">The <see cref="OperationsCollection"/>
        /// whose elements are copied to the new collection.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="collection"/> is a null reference.</exception>
        /// <remarks>Please refer to <see cref="ArrayList(ICollection)"/> for details.</remarks>

        public OperationsCollection(OperationsCollection collection) {
            if (collection == null)
                throw new ArgumentNullException("collection");

            this._array = new Operation[collection.Count];
            AddRange(collection);
        }
 public override void AddRange(OperationsCollection collection) {
     lock (this._root) this._collection.AddRange(collection);
 }
        /// <summary>
        /// Returns a synchronized (thread-safe) wrapper
        /// for the specified <see cref="OperationsCollection"/>.
        /// </summary>
        /// <param name="collection">The <see cref="OperationsCollection"/> to synchronize.</param>
        /// <returns>
        /// A synchronized (thread-safe) wrapper around <paramref name="collection"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="collection"/> is a null reference.</exception>
        /// <remarks>Please refer to <see cref="ArrayList.Synchronized"/> for details.</remarks>

        public static OperationsCollection Synchronized(OperationsCollection collection) {
            if (collection == null)
                throw new ArgumentNullException("collection");

            return new SyncList(collection);
        }
 public override void AddRange(OperationsCollection collection) {
     throw new NotSupportedException(
         "Read-only collections cannot be modified.");
 }
            internal SyncList(OperationsCollection collection):
                base(Tag.Default) {

                this._root = collection.SyncRoot;
                this._collection = collection;
            }
 internal ReadOnlyList(OperationsCollection collection):
     base(Tag.Default) {
     this._collection = collection;
 }
 internal Enumerator(OperationsCollection collection) {
     this._collection = collection;
     this._version = collection._version;
     this._index = -1;
 }
        /// <summary>
        /// Returns a wrapper for the specified <see cref="OperationsCollection"/>
        /// ensuring that all elements are unique.
        /// </summary>
        /// <param name="collection">The <see cref="OperationsCollection"/> to wrap.</param>    
        /// <returns>
        /// A wrapper around <paramref name="collection"/> ensuring that all elements are unique.
        /// </returns>
        /// <exception cref="ArgumentException">
        /// <paramref name="collection"/> contains duplicate elements.</exception>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="collection"/> is a null reference.</exception>
        /// <remarks><para>
        /// The <b>Unique</b> wrapper provides a set-like collection by ensuring
        /// that all elements in the <see cref="OperationsCollection"/> are unique.
        /// </para><para>
        /// <b>Unique</b> raises an <see cref="ArgumentException"/> if the specified 
        /// <paramref name="collection"/> contains any duplicate elements. The returned
        /// wrapper raises a <see cref="NotSupportedException"/> whenever the user attempts 
        /// to add an element that is already contained in the <b>Operations</b>.
        /// </para><para>
        /// <strong>Note:</strong> The <b>Unique</b> wrapper reflects any changes made
        /// to the underlying <paramref name="collection"/>, including the possible
        /// creation of duplicate elements. The uniqueness of all elements is therefore
        /// no longer assured if the underlying collection is manipulated directly.
        /// </para></remarks>

        public static OperationsCollection Unique(OperationsCollection collection) {
            if (collection == null)
                throw new ArgumentNullException("collection");

            for (int i = collection.Count - 1; i > 0; i--)
                if (collection.IndexOf(collection[i]) < i)
                    throw new ArgumentException("Argument cannot contain duplicate elements.", "collection");

            return new UniqueList(collection);
        }
Exemple #14
0
        /// <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;
        }
 internal UniqueList(OperationsCollection collection):
     base(Tag.Default) {
     this._collection = collection;
 }
Exemple #16
0
        /// <summary>
        /// Imports the message parameters for a specified operation from an existing WSDL. 
        /// </summary>
        /// <param name="operations">Collection of operations to import the message parameters from.</param>
        /// <param name="op">The <see cref="Operation"/> to import the message parameters in to.</param>
        /// <param name="output">Indicates whether the current message is input or output.</param>
        /// <param name="parametersCombo">Reference to the combo box which contains the message parameters.</param>
        /// <param name="chkName">Reference to the check box, which indicates whether the customized message name is selected or not.</param>
        /// <param name="tbName">Reference to the text box which contains the customized message name. </param>
        /// <param name="messageLabel">Reference to the Property Pane which contains the message name.</param>
        /// <param name="opDocumentation">Reference to the text box which contains the <see cref="Operation"/>'s documentation.</param>
        /// <param name="msgDocumentation">Reference to the text box which contains the <see cref="Message"/>'s documentation.</param>
        /// <returns>A boolean indicating whether any message parameter is imported or not.</returns>
        /// <param name="originalOperationName">String which contains the original name of the operation. User can always change the operation name after infering operations or while round-tripping. This parameter contains the name of the operation before any of those alternations.</param>		
        private bool ImportMessageParameter(OperationsCollection operations, Operation op, bool output, 
			ComboBox parametersCombo, CheckBox chkName, TextBox tbName, PropertyPane messageLabel, 
			TextBox opDocumentation, TextBox msgDocumentation, string originalOperationName)
        {
            foreach(Operation importedOp in operations)
            {
                if(importedOp.Name == op.Name || (originalOperationName != "" && importedOp.Name == originalOperationName))
                {
                    // Identify the message from the message collection.
                    Message importedMsg = null;
                    Message msg = null;
                    if(!output)
                    {
                        importedMsg = importedOp.Input;
                        msg = op.Input;
                    }
                    else
                    {
                        importedMsg = importedOp.Output;
                        msg = op.Output;
                    }

                    if(importedMsg != null)
                    {
                        // Set the new message parameters.
                        int index = 0;
                        foreach(SchemaElement element in messageSchemas)
                        {
                            if(importedMsg.Element == element)
                            {
                                msg.Element = element;
                                parametersCombo.SelectedIndex = index;
                                break;
                            }
                            index++;
                        }

                        // Enable the custom name text box and put the custom message name in.

                        if(importedOp.Name == op.Name && msg.Name != importedMsg.Name)
                        {
                            tbName.Enabled = true;
                            tbName.Text = importedMsg.Name;
                            msg.Name = importedMsg.Name;
                            messageLabel.Text = importedMsg.Name;
                            chkName.Checked = true;
                        }

                        // Set the Message documentation.
                        msg.Documentation = importedMsg.Documentation;
                        msgDocumentation.Text = importedMsg.Documentation;
                    }

                    // Set the operation documentation.
                    op.Documentation = importedOp.Documentation;
                    opDocumentation.Text = importedOp.Documentation;

                    return true;
                }
            }

            return false;
        }
        /// <summary>
        /// Returns a read-only wrapper for the specified <see cref="OperationsCollection"/>.
        /// </summary>
        /// <param name="collection">The <see cref="OperationsCollection"/> to wrap.</param>
        /// <returns>A read-only wrapper around <paramref name="collection"/>.</returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="collection"/> is a null reference.</exception>
        /// <remarks>Please refer to <see cref="ArrayList.ReadOnly"/> for details.</remarks>

        public static OperationsCollection ReadOnly(OperationsCollection collection) {
            if (collection == null)
                throw new ArgumentNullException("collection");

            return new ReadOnlyList(collection);
        }