Наследование: IMessageList, IList, ICloneable
Пример #1
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);
            }
Пример #2
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;
        }
        /// <overloads>
        /// Adds a range of elements to the end of the <see cref="MessagesCollection"/>.
        /// </overloads>
        /// <summary>
        /// Adds the elements of another collection to the end of the <see cref="MessagesCollection"/>.
        /// </summary>
        /// <param name="collection">The <see cref="MessagesCollection"/> 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="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="collection"/>, 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(MessagesCollection 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="MessagesCollection"/>.
        /// </summary>
        /// <returns>A shallow copy of the <see cref="MessagesCollection"/>.</returns>
        /// <remarks>Please refer to <see cref="ArrayList.Clone"/> for details.</remarks>

        public virtual object Clone() {
        	MessagesCollection collection = new MessagesCollection(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(MessagesCollection collection) {
     foreach (Message value in collection)
         CheckUnique(value);
 
     this._collection.AddRange(collection);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="MessagesCollection"/> 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="MessagesCollection"/>
        /// 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 MessagesCollection(MessagesCollection collection) {
            if (collection == null)
                throw new ArgumentNullException("collection");

            this._array = new Message[collection.Count];
            AddRange(collection);
        }
 public override void AddRange(MessagesCollection collection) {
     lock (this._root) this._collection.AddRange(collection);
 }
 internal UniqueList(MessagesCollection collection):
     base(Tag.Default) {
     this._collection = collection;
 }
 public override void AddRange(MessagesCollection collection) {
     throw new NotSupportedException(
         "Read-only collections cannot be modified.");
 }
            internal SyncList(MessagesCollection collection):
                base(Tag.Default) {

                this._root = collection.SyncRoot;
                this._collection = collection;
            }
 internal ReadOnlyList(MessagesCollection collection):
     base(Tag.Default) {
     this._collection = collection;
 }
 internal Enumerator(MessagesCollection collection) {
     this._collection = collection;
     this._version = collection._version;
     this._index = -1;
 }
        /// <summary>
        /// Returns a wrapper for the specified <see cref="MessagesCollection"/>
        /// ensuring that all elements are unique.
        /// </summary>
        /// <param name="collection">The <see cref="MessagesCollection"/> 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="MessagesCollection"/> 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>Messages</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 MessagesCollection Unique(MessagesCollection 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);
        }
        /// <summary>
        /// Returns a synchronized (thread-safe) wrapper
        /// for the specified <see cref="MessagesCollection"/>.
        /// </summary>
        /// <param name="collection">The <see cref="MessagesCollection"/> 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 MessagesCollection Synchronized(MessagesCollection collection) {
            if (collection == null)
                throw new ArgumentNullException("collection");

            return new SyncList(collection);
        }
        /// <summary>
        /// Returns a read-only wrapper for the specified <see cref="MessagesCollection"/>.
        /// </summary>
        /// <param name="collection">The <see cref="MessagesCollection"/> 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 MessagesCollection ReadOnly(MessagesCollection collection) {
            if (collection == null)
                throw new ArgumentNullException("collection");

            return new ReadOnlyList(collection);
        }