Ejemplo n.º 1
0
        private void AddCorrelationQueryBehaviorToServiceEndpoint(ServiceEndpoint serviceEndpoint)
        {
            Collection <CorrelationQuery> collection;
            XName key = XName.Get(serviceEndpoint.Contract.Name, serviceEndpoint.Contract.Namespace);

            if ((this.correlationQueries != null) && this.correlationQueries.TryGetValue(key, out collection))
            {
                Collection <CorrelationQuery> queries = new Collection <CorrelationQuery>();
                foreach (CorrelationQuery query in collection)
                {
                    if (!queries.Contains(query))
                    {
                        queries.Add(query);
                    }
                    else if (System.ServiceModel.Activities.TD.DuplicateCorrelationQueryIsEnabled())
                    {
                        System.ServiceModel.Activities.TD.DuplicateCorrelationQuery(query.Where.ToString());
                    }
                }
                CorrelationQueryBehavior item = new CorrelationQueryBehavior(queries)
                {
                    ServiceContractName = key
                };
                serviceEndpoint.Behaviors.Add(item);
            }
            else if (CorrelationQueryBehavior.BindingHasDefaultQueries(serviceEndpoint.Binding) && !serviceEndpoint.Behaviors.Contains(typeof(CorrelationQueryBehavior)))
            {
                CorrelationQueryBehavior behavior2 = new CorrelationQueryBehavior(new Collection <CorrelationQuery>())
                {
                    ServiceContractName = key
                };
                serviceEndpoint.Behaviors.Add(behavior2);
            }
        }
Ejemplo n.º 2
0
        void AddCorrelationQueryBehaviorToServiceEndpoint(ServiceEndpoint serviceEndpoint)
        {
            Fx.Assert(serviceEndpoint != null, "Argument cannot be null!");
            Fx.Assert(serviceEndpoint.Contract != null, "ServiceEndpoint must have a contract!");
            Fx.Assert(this.serviceDefinition != null, "Missing WorkflowService!");
            Fx.Assert(!serviceEndpoint.Behaviors.Contains(correlationQueryBehaviorType),
                      "ServiceEndpoint should not have CorrelationQueryBehavior before this point!");

            XName endpointContractName = XName.Get(serviceEndpoint.Contract.Name, serviceEndpoint.Contract.Namespace);

            Collection <CorrelationQuery> queries;

            if (this.correlationQueries != null && this.correlationQueries.TryGetValue(endpointContractName, out queries))
            {
                // Filter out duplicate CorrelationQueries in the collection.
                // Currently, we only do reference comparison and Where message filter comparison.
                Collection <CorrelationQuery> uniqueQueries = new Collection <CorrelationQuery>();
                foreach (CorrelationQuery correlationQuery in queries)
                {
                    if (!uniqueQueries.Contains(correlationQuery))
                    {
                        uniqueQueries.Add(correlationQuery);
                    }
                    else
                    {
                        if (TD.DuplicateCorrelationQueryIsEnabled())
                        {
                            TD.DuplicateCorrelationQuery(correlationQuery.Where.ToString());
                        }
                    }
                }
                serviceEndpoint.Behaviors.Add(new CorrelationQueryBehavior(uniqueQueries)
                {
                    ServiceContractName = endpointContractName
                });
            }
            else if (CorrelationQueryBehavior.BindingHasDefaultQueries(serviceEndpoint.Binding))
            {
                if (!serviceEndpoint.Behaviors.Contains(typeof(CorrelationQueryBehavior)))
                {
                    serviceEndpoint.Behaviors.Add(new CorrelationQueryBehavior(new Collection <CorrelationQuery>())
                    {
                        ServiceContractName = endpointContractName
                    });
                }
            }
        }