Represents a collection of SchemaElement objects.
Наследование: System.Collections.CollectionBase
Пример #1
0
        /// <summary>
        /// Adds the elements in a collection of SchemaElements to the end of the SchemaElements.
        /// </summary>
        /// <param name="values">The SchemaElements collection to add to this collection.</param>
        /// <returns>The number of items in the collection after adding the new SchemaElements.</returns>
        public int AddRange(SchemaElements values)
        {
            foreach (SchemaElement item in values)
            {
                this.InnerList.Add(item);
            }

            return(this.InnerList.Count);
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of SelectHeaderDialog class.
        /// </summary>
        /// <param name="headerSchemas">Reference to an instance of <see cref="SchemaElements"/> class.</param>
        /// <param name="selectedHeader">Reference to an instance of <see cref="SchemaElement"/> class.</param>
        /// <remarks>The headerSchemas parameter contains the header schemas available for the wizard.
        /// This collection is used to fill the cbHeaderMessage combo box later. selectedHeader parameter is
        /// used to return the selected header value from the dialog box to the caller.
        /// </remarks>
        public SelectHeaderDialog(SchemaElements headerSchemas, 
			ref SchemaElement selectedHeader)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.headerSchemas = headerSchemas;
            this.selectedHeader = selectedHeader;

            closingByForce = true;
        }
Пример #3
0
        /// <summary>
        /// Infers the operations according to the message name patterns in the message contracts.
        /// </summary>
        private void InferOperations()
        {
            // Define a hash table with list of request/response patterns.
            Dictionary<string, string> patterns = new Dictionary<string, string>();
            patterns.Add("", "Response");
            patterns.Add("Request", "Response");
            patterns.Add("RequestMessage", "ResponseMessage");

            SchemaElements usedElements = new SchemaElements();

            // Infer two-way operations.
            foreach(SchemaElement melement in messageSchemas)
            {
                foreach(string requestPattern in patterns.Keys)
                {
                    string operationName = "";
                    if(melement.ElementName.EndsWith(requestPattern))
                    {
                        string responsePattern = patterns[requestPattern];

                        // Create the response element.
                        SchemaElement responseElement = new SchemaElement();
                        if(requestPattern == "")
                        {
                            operationName = melement.ElementName;
                            responseElement.ElementName = melement.ElementName + responsePattern;
                        }
                        else
                        {
                            if(melement.ElementName == requestPattern)
                            {
                                operationName = melement.ElementName;
                                responseElement.ElementName = responsePattern;
                            }
                            else
                            {
                                operationName =
                                    melement.ElementName.Substring(0,
                                    melement.ElementName.LastIndexOf(requestPattern));
                                responseElement.ElementName =
                                    melement.ElementName.Substring(0,
                                    melement.ElementName.LastIndexOf(requestPattern)) + responsePattern;
                            }
                        }
                        responseElement.ElementNamespace = melement.ElementNamespace;

                        if(messageSchemas.Contains(responseElement))
                        {
                            // Check whether the operation exists in the imported operations list.
                            bool exists = false;
                            if(importedContract != null)
                            {
                                foreach(Operation impOp in importedContract.OperationsCollection)
                                {
                                    if(impOp.Input.Element == melement &&
                                        (impOp.Output != null && impOp.Output.Element == responseElement))
                                    {
                                        exists = true;
                                        break;
                                    }
                                }
                            }

                            if(exists)
                            {
                                break;
                            }

                            // Add the operation to the list.
                            Operation op = new Operation();
                            op.Name = operationName;
                            op.Documentation = "";
                            op.Mep = Mep.RequestResponse;

                            string opName = op.Name;
                            string opNamePrefix = opName.Substring(0, 1);
                            opNamePrefix = opNamePrefix.ToLower(CultureInfo.CurrentCulture);
                            opName = op.Name.Substring(1, op.Name.Length - 1);
                            opName = opNamePrefix + opName;

                            // Add the input message.
                            Message input = new Message();
                            input.Name = opName + "In";
                            input.Element = melement;
                            input.Documentation = "";
                            op.MessagesCollection.Add(input);
                            op.Input = input;

                            // Add the output message.
                            Message output = new Message();
                            output.Name = opName + "Out";
                            output.Element = responseElement;
                            output.Documentation = "";
                            op.MessagesCollection.Add(output);
                            op.Output = output;

                            // Add the operation to the inferred operations collection.
                            inferOperations.Add(op);

                            // Add the operation to the list view.
                            ListViewItem listViewItem1 =
                                new ListViewItem(new string[] {
                                op.Name,
                                "Request/Response",
                                "",
                                ""},
                                -1);

                            listViewItem1.Tag = op.Name;
                            operationsListView.Items.AddRange(
                                new ListViewItem[] {listViewItem1});

                            usedElements.Add(melement);
                            usedElements.Add(responseElement);
                            // Exit this loop.
                            break;
                        }
                    }
                }
            }

            // Infer one-way operations.
            foreach(SchemaElement melement in messageSchemas)
            {
                foreach(string requestPattern in patterns.Keys)
                {
                    string operationName = "";
                    if(melement.ElementName.EndsWith(requestPattern))
                    {
                        if(!usedElements.Contains(melement))
                        {
                            // Check whether the operation exists in the imported operations list.
                            bool exists = false;
                            if(importedContract != null)
                            {
                                foreach(Operation impOp in importedContract.OperationsCollection)
                                {
                                    if(impOp.Input.Element == melement  ||
                                        (impOp.Output != null && impOp.Output.Element == melement))
                                    {
                                        exists = true;
                                        break;
                                    }
                                }
                            }

                            if(exists)
                            {
                                break;
                            }

                            // Compose the operation name.
                            if(requestPattern == "")
                            {
                                operationName = melement.ElementName;
                            }
                            else
                            {
                                if(melement.ElementName == requestPattern)
                                {
                                    operationName = melement.ElementName;
                                }
                                else
                                {
                                    operationName =
                                        melement.ElementName.Substring(0,
                                        melement.ElementName.LastIndexOf(requestPattern));
                                }
                            }

                            // Add the operation to the list.
                            Operation op = new Operation();
                            op.Name = operationName;
                            op.Documentation = "";
                            op.Mep = Mep.OneWay;

                            string opName = op.Name;
                            string opNamePrefix = opName.Substring(0, 1);
                            opNamePrefix = opNamePrefix.ToLower(CultureInfo.CurrentCulture);
                            opName = op.Name.Substring(1, op.Name.Length - 1);
                            opName = opNamePrefix + opName;

                            // Add the input message.
                            Message input = new Message();
                            input.Name = opName + "In";
                            input.Element = melement;
                            input.Documentation = "";
                            op.MessagesCollection.Add(input);
                            op.Input = input;

                            // Add the operation to the inferred operations collection.
                            inferOperations.Add(op);

                            // Add the operation to the list view.
                            ListViewItem listViewItem1 =
                                new ListViewItem(new string[] {
                                    op.Name,
                                    "One-Way",
                                    "",
                                    ""},
                                -1);

                            listViewItem1.Tag = op.Name;
                            operationsListView.Items.AddRange(
                                new ListViewItem[] {listViewItem1});
                        }
                        // Exit this loop.
                        break;
                    }
                }
            }
        }
Пример #4
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 in a collection of SchemaElements to the end of the SchemaElements.
		/// </summary>
		/// <param name="values">The SchemaElements collection to add to this collection.</param>
		/// <returns>The number of items in the collection after adding the new SchemaElements.</returns>
		public int AddRange(SchemaElements values)
		{
			foreach(SchemaElement item in values)
			{
				this.InnerList.Add(item);
			}

			return this.InnerList.Count;
		}
		/// <summary>
		/// Initializes a new instance of the InterfaceContract class.
		/// </summary>
		public InterfaceContract()
		{
			types = new SchemaElements();
			isHttpBinding = false;
            bindings |= SoapBindings.Soap11;
		}
		/// <summary>
		/// Initializes the <see cref="Type"/> property.
		/// </summary>
		/// <param name="schemaElements">
		/// An instance of <see cref="SchemaElements"/> class.
		/// </param>
		/// <remarks>This method is accessible only within the assembly.</remarks>
		internal void SetTypes(SchemaElements schemaElements)
		{
			this.types.AddRange(schemaElements);
		}
        /// <summary>
        /// Reads a XML schema file and returns the information found in that.
        /// </summary>
        /// <param name="schemaFile">The XML schema file to read information from.</param>
        /// <param name="schemaNamespace">Ouput parameter which returns the namespace of the specified XML schema file.</param>
        /// <returns>
        /// An <see cref="ArrayList"/> with three items. 
        /// 1. Contains an <see cref="ArrayList"/> of <see cref="XmlSchemaElement"/> objects.
        /// 2. Contains an <see cref="ArrayList"/> of schema element names.
        /// 3. Contains a <see cref="SchemaElements"/> object. 
        /// </returns>
        public static ArrayList GetSchemasFromXsd(string schemaFile, out string schemaNamespace)
        {
            XmlTextReader reader = null;
            ArrayList schemas;
            ArrayList schemaNames;
            SchemaElements sElements;

            try
            {
                reader = new XmlTextReader(schemaFile);

                XmlSchema schema = XmlSchema.Read(reader, null);
                string schemaTargetNamesapce = schema.TargetNamespace;
                schemaNamespace = schemaTargetNamesapce;

                ArrayList xmlSchemaElements = new ArrayList();
                schemas = new ArrayList();
                schemaNames = new ArrayList();
                sElements = new SchemaElements();

                foreach (XmlSchemaObject xmlObj in schema.Items)
                {
                    if (xmlObj is XmlSchemaAnnotated) xmlSchemaElements.Add(xmlObj);
                }

                foreach (XmlSchemaAnnotated obj in xmlSchemaElements)
                {
                    if (obj is XmlSchemaElement)
                    {
                        XmlSchemaElement xse = (XmlSchemaElement)obj;

                        schemas.Add(xse);
                        schemaNames.Add(xse.Name);
                        sElements.Add(new SchemaElement(schemaTargetNamesapce, xse.Name));
                    }
                }

                reader.Close();

                ArrayList result = new ArrayList();
                result.Add(schemas);
                result.Add(sElements);
                result.Add(schemaNames);

                return result;
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException("Error occurred while reading the schema file.", ex);
            }
            finally
            {
                if (reader != null && reader.ReadState != ReadState.Closed)
                {
                    reader.Close();
                }
            }
        }
        /// <summary>
        /// Extracts the elements from a given schemas.
        /// </summary>
        /// <param name="schemas">Schemas to extract the elements from.</param>
        /// <param name="tns">String specifying the target namespace of the <see cref="schemas" />.</param>
        /// <returns>An instance of <see cref="SchemaElements" /> class which contains the extracted elements.</returns>
        private static SchemaElements GetSchemaElements(XmlSchemas schemas, string tns)
        {
            ArrayList xmlSchemaElements = new ArrayList();
            SchemaElements sElements = new SchemaElements();

            foreach (XmlSchema schema in schemas)
            {
                foreach (XmlSchemaObject xmlObj in schema.Items)
                {
                    if (xmlObj is XmlSchemaAnnotated)
                    {
                        if (xmlObj is XmlSchemaElement)
                        {
                            XmlSchemaElement xse = (XmlSchemaElement)xmlObj;
                            sElements.Add(new SchemaElement(tns, xse.Name));
                        }
                    }
                }
            }

            return sElements;
        }
Пример #10
0
 /// <summary>
 /// Initializes a new instance of the InterfaceContract class.
 /// </summary>
 public InterfaceContract()
 {
     types         = new SchemaElements();
     isHttpBinding = false;
     bindings     |= SoapBindings.Soap11;
 }
Пример #11
0
 /// <summary>
 /// Initializes the <see cref="Type"/> property.
 /// </summary>
 /// <param name="schemaElements">
 /// An instance of <see cref="SchemaElements"/> class.
 /// </param>
 /// <remarks>This method is accessible only within the assembly.</remarks>
 internal void SetTypes(SchemaElements schemaElements)
 {
     this.types.AddRange(schemaElements);
 }