/// <summary> /// Initializes a new instance of SelectHeaderDialog class. /// </summary> /// <param name="headerSchemas">Reference to a list of schema elements.</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(List<SchemaElement> headerSchemas, ref SchemaElement selectedHeader) { // // Required for Windows Form Designer support // InitializeComponent(); this.headerSchemas = headerSchemas; this.selectedHeader = selectedHeader; closingByForce = true; }
/// <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> /// Initializes a new instance of the Message class. /// </summary> public Message() { Element = new SchemaElement(); }
private void InferRequestResponseOperations() { // Infer two-way operations. foreach (SchemaElement melement in MessageSchemas) { foreach (string pattern in operationNamePatterns.Keys) { string operationName = ""; if (melement.ElementName.EndsWith(pattern)) { string responsePattern = operationNamePatterns[pattern].ToString(); // Create the response element. SchemaElement responseElement = new SchemaElement(); if (pattern == "") { operationName = melement.ElementName; responseElement.ElementName = melement.ElementName + responsePattern; } else { if (melement.ElementName == pattern) { operationName = melement.ElementName; responseElement.ElementName = responsePattern; } else { operationName = melement.ElementName.Substring(0, melement.ElementName.LastIndexOf(pattern)); responseElement.ElementName = melement.ElementName.Substring(0, melement.ElementName.LastIndexOf(pattern)) + responsePattern; } } responseElement.ElementNamespace = melement.ElementNamespace; if (MessageSchemas.Contains(responseElement)) { // Check whether the operation exists in the imported operations list. bool exists = false; foreach (Operation impOp in this.Operations) { 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. this.twoWayOperations.Add(op); this.Operations.Add(op); // Exit this loop. break; } } } } }
private void InferRequestResponseOperations() { // Infer two-way operations. foreach (SchemaElement melement in MessageSchemas) { foreach (string pattern in operationNamePatterns.Keys) { string operationName = ""; if (melement.ElementName.EndsWith(pattern)) { string responsePattern = operationNamePatterns[pattern].ToString(); // Create the response element. SchemaElement responseElement = new SchemaElement(); if (pattern == "") { operationName = melement.ElementName; responseElement.ElementName = melement.ElementName + responsePattern; } else { if (melement.ElementName == pattern) { operationName = melement.ElementName; responseElement.ElementName = responsePattern; } else { operationName = melement.ElementName.Substring(0, melement.ElementName.LastIndexOf(pattern)); responseElement.ElementName = melement.ElementName.Substring(0, melement.ElementName.LastIndexOf(pattern)) + responsePattern; } } responseElement.ElementNamespace = melement.ElementNamespace; if (MessageSchemas.Contains(responseElement)) { // Check whether the operation exists in the imported operations list. bool exists = false; foreach (Operation impOp in this.Operations) { 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. this.twoWayOperations.Add(op); this.Operations.Add(op); // Exit this loop. break; } } } } }