public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher) { ICorrelationDataSource property = endpoint.Binding.GetProperty <ICorrelationDataSource>(new BindingParameterCollection()); if (property != null) { this.ConfigureBindingDataNames(property); this.ConfigureBindingDefaultQueries(endpoint, property, true); } System.ServiceModel.Description.ServiceDescription description = endpointDispatcher.ChannelDispatcher.Host.Description; WorkflowServiceHost host = endpointDispatcher.ChannelDispatcher.Host as WorkflowServiceHost; if (host == null) { this.ScopeName = XNamespace.Get(description.Namespace).GetName(description.Name); } else { this.ScopeName = host.DurableInstancingOptions.ScopeName; } endpointDispatcher.ChannelDispatcher.ChannelInitializers.Add(this); if (this.shouldPreserveMessage) { endpointDispatcher.DispatchRuntime.PreserveMessage = true; } }
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher) { ICorrelationDataSource source = endpoint.Binding.GetProperty <ICorrelationDataSource>(new BindingParameterCollection()); if (source != null) { this.ConfigureBindingDataNames(source); this.ConfigureBindingDefaultQueries(endpoint, source, true); } ServiceDescription description = endpointDispatcher.ChannelDispatcher.Host.Description; WorkflowServiceHost host = endpointDispatcher.ChannelDispatcher.Host as WorkflowServiceHost; if (host == null) { // setup the scope name to be the Namespace + Name of the ServiceDescription. This will be // either have been explicitly set by WorkflowService.Name or defaulted through the infrastructure this.ScopeName = XNamespace.Get(description.Namespace).GetName(description.Name); } else { this.ScopeName = host.DurableInstancingOptions.ScopeName; } endpointDispatcher.ChannelDispatcher.ChannelInitializers.Add(this); if (this.shouldPreserveMessage) { // there could be a query that might be read from the message body // let us buffer the message at the dispatcher endpointDispatcher.DispatchRuntime.PreserveMessage = true; } }
public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime) { ICorrelationDataSource source = endpoint.Binding.GetProperty <ICorrelationDataSource>(new BindingParameterCollection()); if (source != null) { this.ConfigureBindingDataNames(source); this.ConfigureBindingDefaultQueries(endpoint, source, false); } }
public static ICorrelationDataSource Combine(ICorrelationDataSource dataSource1, ICorrelationDataSource dataSource2) { if (dataSource1 == null) { return dataSource2; } if (dataSource2 == null) { return dataSource1; } return new CorrelationDataSourceHelper(dataSource1.DataSources, dataSource2.DataSources); }
public static ICorrelationDataSource Combine(ICorrelationDataSource dataSource1, ICorrelationDataSource dataSource2) { if (dataSource1 == null) { return(dataSource2); } if (dataSource2 == null) { return(dataSource1); } return(new CorrelationDataSourceHelper(dataSource1.DataSources, dataSource2.DataSources)); }
public static bool BindingHasDefaultQueries(Binding binding) { ICorrelationDataSource property = binding.GetProperty <ICorrelationDataSource>(new BindingParameterCollection()); if (property != null) { foreach (CorrelationDataDescription description in property.DataSources) { if (description.IsDefault) { return(true); } } } return(false); }
public override T GetProperty <T>(BindingContext context) { if (context == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context"); } if (typeof(T) == typeof(ChannelProtectionRequirements) && this.ProtectionLevel != ProtectionLevel.None) { ChannelProtectionRequirements innerRequirements = context.GetInnerProperty <ChannelProtectionRequirements>(); if (innerRequirements == null) { return((T)(object)ContextMessageHeader.GetChannelProtectionRequirements(this.ProtectionLevel)); } else { ChannelProtectionRequirements requirements = new ChannelProtectionRequirements(innerRequirements); requirements.Add(ContextMessageHeader.GetChannelProtectionRequirements(this.ProtectionLevel)); return((T)(object)requirements); } } else if (typeof(T) == typeof(IContextSessionProvider)) { return((T)(object)this); } else if (typeof(T) == typeof(IContextBindingElement)) { return((T)(object)this); } else if (typeof(T) == typeof(ICorrelationDataSource)) { ICorrelationDataSource correlationData = instanceCorrelationData; if (correlationData == null) { ICorrelationDataSource innerCorrelationData = context.GetInnerProperty <ICorrelationDataSource>(); correlationData = CorrelationDataSourceHelper.Combine(innerCorrelationData, ContextExchangeCorrelationDataDescription.DataSource); instanceCorrelationData = correlationData; } return((T)(object)correlationData); } return(context.GetInnerProperty <T>()); }
public static bool BindingHasDefaultQueries(Binding binding) { ICorrelationDataSource source = binding.GetProperty <ICorrelationDataSource>(new BindingParameterCollection()); bool hasDefaults = false; if (source != null) { foreach (CorrelationDataDescription data in source.DataSources) { if (data.IsDefault) { hasDefaults = true; break; } } } return(hasDefaults); }
private void ConfigureBindingDataNames(ICorrelationDataSource source) { List <string> list = new List <string>(); List <string> list2 = new List <string>(); foreach (CorrelationDataDescription description in source.DataSources) { if (description.ReceiveValue) { list.Add(description.Name); } if (description.SendValue && ((description.Name != "http-cookie") || this.IsCookieBasedQueryPresent())) { list2.Add(description.Name); } } this.receiveNames = new ReadOnlyCollection <string>(list); this.sendNames = new ReadOnlyCollection <string>(list2); }
public override T GetProperty <T>(BindingContext context) where T : class { if (context == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context"); } if ((typeof(T) == typeof(ChannelProtectionRequirements)) && (this.ProtectionLevel != System.Net.Security.ProtectionLevel.None)) { ChannelProtectionRequirements innerProperty = context.GetInnerProperty <ChannelProtectionRequirements>(); if (innerProperty == null) { return((T)ContextMessageHeader.GetChannelProtectionRequirements(this.ProtectionLevel)); } ChannelProtectionRequirements requirements2 = new ChannelProtectionRequirements(innerProperty); requirements2.Add(ContextMessageHeader.GetChannelProtectionRequirements(this.ProtectionLevel)); return((T)requirements2); } if (typeof(T) == typeof(IContextSessionProvider)) { return((T)this); } if (typeof(T) == typeof(IContextBindingElement)) { return((T)this); } if (!(typeof(T) == typeof(ICorrelationDataSource))) { return(context.GetInnerProperty <T>()); } ICorrelationDataSource instanceCorrelationData = this.instanceCorrelationData; if (instanceCorrelationData == null) { instanceCorrelationData = CorrelationDataSourceHelper.Combine(context.GetInnerProperty <ICorrelationDataSource>(), ContextExchangeCorrelationDataDescription.DataSource); this.instanceCorrelationData = instanceCorrelationData; } return((T)instanceCorrelationData); }
void ConfigureBindingDataNames(ICorrelationDataSource source) { List <string> receiveNames = new List <string>(); List <string> sendNames = new List <string>(); foreach (CorrelationDataDescription data in source.DataSources) { if (data.ReceiveValue) { receiveNames.Add(data.Name); } // we want to optimize the correlation path for Send/SendReply cases, // when using httpbinding, we always have 'http-cookie' added by transport, so we // add data.name even when we don't have a query. This results in postponing the correlation key calculation // till the channel calls us back. if (data.SendValue) { // if the data.Name is for cookie, but there is no user added query for the cookie, we will not // add this to sendNames. // Note that we only look at user added queries. This is because http-cookie does not have a default query // if (data.Name == cookieCorrelationName && !this.IsCookieBasedQueryPresent()) { continue; } else { sendNames.Add(data.Name); } } } this.receiveNames = new ReadOnlyCollection <string>(receiveNames); this.sendNames = new ReadOnlyCollection <string>(sendNames); }
void ConfigureBindingDefaultQueries(ServiceEndpoint endpoint, ICorrelationDataSource source, bool dispatch) { if (!CorrelationQuery.IsQueryCollectionSearchable(this.queries)) { return; } // we should preserve the message if there are any existing queries added by the user if (this.queries.Count <= 0) { this.shouldPreserveMessage = false; } foreach (OperationDescription operation in endpoint.Contract.Operations) { string inAction; CorrelationQuery inQuery; string outAction = null; CorrelationQuery outQuery = null; CorrelationQuery noActionReplyQuery = null; inAction = operation.Messages[0].Action; inQuery = CorrelationQuery.FindCorrelationQueryForAction(this.queries, inAction); if (!operation.IsOneWay) { outAction = operation.Messages[1].Action; outQuery = CorrelationQuery.FindCorrelationQueryForAction(this.queries, outAction); if (!dispatch) { noActionReplyQuery = CorrelationQuery.FindCorrelationQueryForAction(this.queries, String.Empty); } } // we will not add default query if a query already exists for the action bool canDefaultIn = inQuery == null; bool canDefaultOut = !operation.IsOneWay && outQuery == null; // if there are no user added queries for receiveReply, we add a NoActionQuery bool addNoActionQueryForReply = !operation.IsOneWay && !dispatch && noActionReplyQuery == null; // On the client side we add special filters, SendFilter and ReceiveFilter // But on dispatch side, we use ActionFilter and therefore need to verify that for wildcardaction, we // only add a single defaultquery if (canDefaultIn && canDefaultOut) { //verify if any of them is a wildcardaction, in that case let's just add a single query with a MatchAllFilter if (inAction == MessageHeaders.WildcardAction) { canDefaultOut = false; } else if (outAction == MessageHeaders.WildcardAction) { canDefaultIn = false; } else if (inAction == outAction) { // in this case we will be adding the same query twice, let's just add once // a possible scenario is when we add a contractDescription with wildcardaction for request & reply canDefaultOut = false; } } if (!canDefaultIn && !canDefaultOut) { continue; } foreach (CorrelationDataDescription data in source.DataSources) { if (!data.IsDefault) { continue; } if (canDefaultIn && (dispatch && data.ReceiveValue || data.SendValue)) { inQuery = CreateDefaultCorrelationQuery(inQuery, inAction, data, ref shouldPreserveMessage); } if (canDefaultOut && (dispatch && data.SendValue || data.ReceiveValue)) { outQuery = CreateDefaultCorrelationQuery(outQuery, outAction, data, ref shouldPreserveMessage); } if (addNoActionQueryForReply) { noActionReplyQuery = CreateDefaultCorrelationQuery(noActionReplyQuery, String.Empty, data, ref shouldPreserveMessage); } } if (canDefaultIn && inQuery != null) { this.queries.Add(inQuery); } if (canDefaultOut && outQuery != null) { this.queries.Add(outQuery); } if (addNoActionQueryForReply && noActionReplyQuery != null) { this.queries.Add(noActionReplyQuery); } } }
private void ConfigureBindingDefaultQueries(ServiceEndpoint endpoint, ICorrelationDataSource source, bool dispatch) { if (CorrelationQuery.IsQueryCollectionSearchable(this.queries)) { if (this.queries.Count <= 0) { this.shouldPreserveMessage = false; } foreach (OperationDescription description in endpoint.Contract.Operations) { string action = null; CorrelationQuery query2 = null; CorrelationQuery query3 = null; string str = description.Messages[0].Action; CorrelationQuery query = CorrelationQuery.FindCorrelationQueryForAction(this.queries, str); if (!description.IsOneWay) { action = description.Messages[1].Action; query2 = CorrelationQuery.FindCorrelationQueryForAction(this.queries, action); if (!dispatch) { query3 = CorrelationQuery.FindCorrelationQueryForAction(this.queries, string.Empty); } } bool flag = query == null; bool flag2 = !description.IsOneWay && (query2 == null); bool flag3 = (!description.IsOneWay && !dispatch) && (query3 == null); if (flag && flag2) { if (str == "*") { flag2 = false; } else if (action == "*") { flag = false; } else if (str == action) { flag2 = false; } } if (flag || flag2) { foreach (CorrelationDataDescription description2 in source.DataSources) { if (description2.IsDefault) { if (flag && ((dispatch && description2.ReceiveValue) || description2.SendValue)) { query = CreateDefaultCorrelationQuery(query, str, description2, ref this.shouldPreserveMessage); } if (flag2 && ((dispatch && description2.SendValue) || description2.ReceiveValue)) { query2 = CreateDefaultCorrelationQuery(query2, action, description2, ref this.shouldPreserveMessage); } if (flag3) { query3 = CreateDefaultCorrelationQuery(query3, string.Empty, description2, ref this.shouldPreserveMessage); } } } if (flag && (query != null)) { this.queries.Add(query); } if (flag2 && (query2 != null)) { this.queries.Add(query2); } if (flag3 && (query3 != null)) { this.queries.Add(query3); } } } } }