static CorrelationQuery CreateDefaultCorrelationQuery(CorrelationQuery query, string action, CorrelationDataDescription data, ref bool shouldPreserveMessage) { MessageQuery messageQuery = new XPathMessageQuery { Expression = string.Format(CultureInfo.InvariantCulture, defaultQueryFormat, data.Name), Namespaces = new XPathMessageContext() }; if (data.IsOptional) { messageQuery = new OptionalMessageQuery { Query = messageQuery }; } if (query == null) { MessageFilter filter; // verify if the data name is added by the context channel bool isContextQuery = (data.Name == contextCorrelationName); // if there is a query that is not a context query set it to true since we might read from // the message body if (!shouldPreserveMessage && !isContextQuery) { shouldPreserveMessage = true; } // this is a server side query, we use an action filter if (action == MessageHeaders.WildcardAction) { filter = new MatchAllMessageFilter(); } else { filter = new ActionMessageFilter(action); } return(new CorrelationQuery { Where = filter, IsDefaultContextQuery = isContextQuery, Select = new MessageQuerySet { { data.Name, messageQuery } } }); } else { query.Select[data.Name] = messageQuery; return(query); } }
// Wrapper code that encapsulates creating a simple message query for the purposes of the sample static MessageQuerySet CreateMessageQuerySet(string query) { XPathMessageQuery xpathQuery = new XPathMessageQuery(query); MessageQuerySet mqs = new MessageQuerySet(); mqs.Add("accountQuery", xpathQuery); return(mqs); }
public override IList <string> Convert(object value) { IList <string> results = new List <string>(); XPathMessageQuery messageQuery = value as XPathMessageQuery; if (messageQuery != null) { results.Add(messageQuery.Expression); } return(results); }
protected override void SetItem(int index, MessageQuery item) { if (!(item is XPathMessageQuery)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("item"); } this.matcher.Remove((XPathMessageQuery) base[index]); XPathMessageQuery query = (XPathMessageQuery)item; base.SetItem(index, item); this.matcher.Add(query.Expression, query.Namespaces, query, false); }
protected override void InsertItem(int index, MessageQuery item) { if (item == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("item"); } if (!(item is XPathMessageQuery)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("item"); } base.InsertItem(index, item); XPathMessageQuery query = (XPathMessageQuery)item; this.matcher.Add(query.Expression, query.Namespaces, query, false); }
private static CorrelationQuery CreateDefaultCorrelationQuery(CorrelationQuery query, string action, CorrelationDataDescription data, ref bool shouldPreserveMessage) { XPathMessageQuery query5 = new XPathMessageQuery { Expression = string.Format(CultureInfo.InvariantCulture, "sm:correlation-data('{0}')", new object[] { data.Name }), Namespaces = new XPathMessageContext() }; MessageQuery query2 = query5; if (data.IsOptional) { OptionalMessageQuery query3 = new OptionalMessageQuery { Query = query2 }; query2 = query3; } if (query == null) { MessageFilter filter; bool flag = data.Name == "wsc-instanceId"; if (!shouldPreserveMessage && !flag) { shouldPreserveMessage = true; } if (action == "*") { filter = new MatchAllMessageFilter(); } else { filter = new ActionMessageFilter(new string[] { action }); } CorrelationQuery query4 = new CorrelationQuery { Where = filter, IsDefaultContextQuery = flag }; MessageQuerySet set = new MessageQuerySet(); set.Add(data.Name, query2); query4.Select = set; return(query4); } query.Select[data.Name] = query2; return(query); }
/// <summary> /// Generate the correlation hash /// </summary> /// <returns>MessageQuerySet</returns> private MessageQuerySet CreateCorrelationQuery() { var xpath = new XPathMessageQuery { Namespaces = new XmlNamespaceManager(new NameTable()), Expression = "//sample:WorkflowId" }; xpath.Namespaces.AddNamespace("sample", MessageNamespace); var messageQuerySet = new MessageQuerySet { Name = "RequestCorrelation" }; messageQuerySet.Add("WorkflowId", xpath); return(messageQuerySet); }
internal bool IsCookieBasedQueryPresent() { if (this.queries.Count > 0) { foreach (CorrelationQuery query in this.queries) { foreach (MessageQuerySet set in query.SelectAdditional) { foreach (KeyValuePair <string, MessageQuery> pair in set) { XPathMessageQuery query2 = pair.Value as XPathMessageQuery; if ((query2 != null) && query2.Expression.Equals(xPathForCookie)) { return(true); } } } } } return(false); }
internal bool IsCookieBasedQueryPresent() { if (this.queries.Count > 0) { foreach (CorrelationQuery query in this.queries) { // we only need to look at queries for selectAdditional since this query should be always initializing foreach (MessageQuerySet messageQueryset in query.SelectAdditional) { foreach (KeyValuePair <string, MessageQuery> item in messageQueryset) { XPathMessageQuery xPathQuery = item.Value as XPathMessageQuery; if (xPathQuery != null && xPathQuery.Expression.Equals(xPathForCookie)) { return(true); } } } } } return(false); }
// Wrapper code that encapsulates creating a simple message query for the purposes of the sample static MessageQuerySet CreateMessageQuerySet(string query) { XPathMessageQuery xpathQuery = new XPathMessageQuery(query); MessageQuerySet mqs = new MessageQuerySet(); mqs.Add("accountQuery", xpathQuery); return mqs; }
void OnTypeSelectionChanged(object sender, RoutedEventArgs e) { var contentCorrelationDesigner = (ContentCorrelationTypeExpander)sender; //is selection valid (valid type or property) if (contentCorrelationDesigner.IsSelectionValid) { var path = contentCorrelationDesigner.GetMemberPath(); var type = contentCorrelationDesigner.GetSelectedType(); try { XmlNamespaceManager namespaceManager = null; string xpathQuery = string.Empty; var content = this.Activity.Properties["Content"].Value; if (content.IsAssignableFrom <ReceiveMessageContent>() || content.IsAssignableFrom <SendMessageContent>()) { //generating xpath for message content xpathQuery = XPathQueryGenerator.CreateFromDataContractSerializer(type, path, out namespaceManager); } else { //generating xpath for parameter content XName serviceContractName = null; string operationName = null; string parameterName = contentCorrelationDesigner.SelectedTypeEntry.Name; bool isReply = this.Activity.IsAssignableFrom <SendReply>() || this.Activity.IsAssignableFrom <ReceiveReply>(); if (isReply) { operationName = (string)this.Activity.Properties["Request"].Value.Properties["OperationName"].ComputedValue; serviceContractName = (XName)this.Activity.Properties["Request"].Value.Properties["ServiceContractName"].ComputedValue; if (string.IsNullOrEmpty(operationName) || null == serviceContractName) { ModelItem requestDisplayName; this.Activity.TryGetPropertyValue(out requestDisplayName, "Request", "DisplayName"); throw FxTrace.Exception.AsError(new InvalidOperationException( string.Format(CultureInfo.CurrentUICulture, (string)this.FindResource("parametersRequiredText"), requestDisplayName.GetCurrentValue()))); } } else { operationName = (string)this.Activity.Properties["OperationName"].ComputedValue; serviceContractName = (XName)this.Activity.Properties["ServiceContractName"].ComputedValue; if (string.IsNullOrEmpty(operationName) || null == serviceContractName) { throw FxTrace.Exception.AsError(new InvalidOperationException( string.Format(CultureInfo.CurrentUICulture, (string)this.FindResource("parametersRequiredText"), this.Activity.Properties["DisplayName"].ComputedValue))); } } xpathQuery = ParameterXPathQueryGenerator.CreateFromDataContractSerializer(serviceContractName, operationName, parameterName, isReply, type, path, out namespaceManager); } //use CDF api to build a xpath out of type and its properties string xpath = string.Format(CultureInfo.InvariantCulture, "sm:body(){0}", xpathQuery); //get the context //We need to copy over the namespaces from the manager's table 1 by 1. According to MSDN: //If you specify an existing name table, any namespaces in the name table are not automatically added to XmlNamespaceManager. //You must use AddNamespace and RemoveNamespace to add or remove namespaces. XPathMessageContext messageContext = new XPathMessageContext(); foreach (string prefix in namespaceManager) { if (!string.IsNullOrEmpty(prefix) && !messageContext.HasNamespace(prefix) && prefix != "xmlns") { messageContext.AddNamespace(prefix, namespaceManager.LookupNamespace(prefix)); } } var typeEntry = (ExpanderTypeEntry)contentCorrelationDesigner.Tag; //construct xpath XPathMessageQuery query = new XPathMessageQuery(xpath, messageContext); //store the xpath in the Tag property; this combo's selectedValue is bound to i typeEntry.Tag = query; this.SelectedIndex = 0; this.IsDropDownOpen = false; this.Query = query; this.RaiseEvent(new RoutedEventArgs(XPathCreatedEvent, this)); } catch (Exception err) { MessageBox.Show( err.Message, (string)this.Resources["controlTitle"], MessageBoxButton.OK, MessageBoxImage.Error); } } }
void OnTypeSelectionChanged(object sender, RoutedEventArgs e) { var contentCorrelationDesigner = (ContentCorrelationTypeExpander)sender; //is selection valid (valid type or property) if (contentCorrelationDesigner.IsSelectionValid) { var path = contentCorrelationDesigner.GetMemberPath(); var type = contentCorrelationDesigner.GetSelectedType(); try { XmlNamespaceManager namespaceManager = null; string xpathQuery = string.Empty; var content = this.Activity.Properties["Content"].Value; if (content.IsAssignableFrom<ReceiveMessageContent>() || content.IsAssignableFrom<SendMessageContent>()) { //generating xpath for message content xpathQuery = XPathQueryGenerator.CreateFromDataContractSerializer(type, path, out namespaceManager); } else { //generating xpath for parameter content XName serviceContractName = null; string operationName = null; string parameterName = contentCorrelationDesigner.SelectedTypeEntry.Name; bool isReply = this.Activity.IsAssignableFrom<SendReply>() || this.Activity.IsAssignableFrom<ReceiveReply>(); if (isReply) { operationName = (string)this.Activity.Properties["Request"].Value.Properties["OperationName"].ComputedValue; serviceContractName = (XName)this.Activity.Properties["Request"].Value.Properties["ServiceContractName"].ComputedValue; if (string.IsNullOrEmpty(operationName) || null == serviceContractName) { ModelItem requestDisplayName; this.Activity.TryGetPropertyValue(out requestDisplayName, "Request", "DisplayName"); throw FxTrace.Exception.AsError(new InvalidOperationException( string.Format(CultureInfo.CurrentUICulture, (string)this.FindResource("parametersRequiredText"), requestDisplayName.GetCurrentValue()))); } } else { operationName = (string)this.Activity.Properties["OperationName"].ComputedValue; serviceContractName = (XName)this.Activity.Properties["ServiceContractName"].ComputedValue; if (string.IsNullOrEmpty(operationName) || null == serviceContractName) { throw FxTrace.Exception.AsError(new InvalidOperationException( string.Format(CultureInfo.CurrentUICulture, (string)this.FindResource("parametersRequiredText"), this.Activity.Properties["DisplayName"].ComputedValue))); } } xpathQuery = ParameterXPathQueryGenerator.CreateFromDataContractSerializer(serviceContractName, operationName, parameterName, isReply, type, path, out namespaceManager); } //use CDF api to build a xpath out of type and its properties string xpath = string.Format(CultureInfo.InvariantCulture, "sm:body(){0}", xpathQuery); //get the context //We need to copy over the namespaces from the manager's table 1 by 1. According to MSDN: //If you specify an existing name table, any namespaces in the name table are not automatically added to XmlNamespaceManager. //You must use AddNamespace and RemoveNamespace to add or remove namespaces. XPathMessageContext messageContext = new XPathMessageContext(); foreach (string prefix in namespaceManager) { if (!string.IsNullOrEmpty(prefix) && !messageContext.HasNamespace(prefix) && prefix != "xmlns") { messageContext.AddNamespace(prefix, namespaceManager.LookupNamespace(prefix)); } } var typeEntry = (ExpanderTypeEntry)contentCorrelationDesigner.Tag; //construct xpath XPathMessageQuery query = new XPathMessageQuery(xpath, messageContext); //store the xpath in the Tag property; this combo's selectedValue is bound to i typeEntry.Tag = query; this.SelectedIndex = 0; this.IsDropDownOpen = false; this.Query = query; this.RaiseEvent(new RoutedEventArgs(XPathCreatedEvent, this)); } catch (Exception err) { MessageBox.Show( err.Message, (string)this.Resources["controlTitle"], MessageBoxButton.OK, MessageBoxImage.Error); } } }