internal IDictionary<XName, ContractDescription> GetContractDescriptions()
 {
     if (this.cachedInferredContracts == null)
     {
         this.WalkActivityTree();
         this.correlationQueryByContract = new Dictionary<XName, Collection<CorrelationQuery>>();
         IDictionary<XName, ContractDescription> dictionary = new Dictionary<XName, ContractDescription>();
         IDictionary<ContractAndOperationNameTuple, OperationInfo> dictionary2 = new Dictionary<ContractAndOperationNameTuple, OperationInfo>();
         foreach (Receive receive in this.knownServiceActivities)
         {
             OperationInfo info;
             XName serviceContractXName = this.FixServiceContractName(receive.ServiceContractName);
             ContractAndOperationNameTuple key = new ContractAndOperationNameTuple(serviceContractXName, receive.OperationName);
             if (dictionary2.TryGetValue(key, out info))
             {
                 ContractValidationHelper.ValidateReceiveWithReceive(receive, info.Receive);
             }
             else
             {
                 ContractDescription description;
                 if (!dictionary.TryGetValue(serviceContractXName, out description))
                 {
                     description = new ContractDescription(serviceContractXName.LocalName, serviceContractXName.NamespaceName) {
                         ConfigurationName = serviceContractXName.LocalName
                     };
                     dictionary.Add(serviceContractXName, description);
                 }
                 OperationDescription item = ContractInferenceHelper.CreateOperationDescription(receive, description);
                 description.Operations.Add(item);
                 info = new OperationInfo(receive, item);
                 dictionary2.Add(key, info);
             }
             this.CorrectOutMessageForOperationWithFault(receive, info);
             ContractInferenceHelper.UpdateIsOneWayFlag(receive, info.OperationDescription);
             ContractInferenceHelper.AddFaultDescription(receive, info.OperationDescription);
             ContractInferenceHelper.AddKnownTypesToOperation(receive, info.OperationDescription);
             ContractInferenceHelper.AddReceiveToFormatterBehavior(receive, info.OperationDescription);
             Collection<CorrelationQuery> queries = null;
             if (receive.HasCorrelatesOn || receive.HasCorrelationInitializers)
             {
                 MessageQuerySet select = receive.HasCorrelatesOn ? receive.CorrelatesOn : null;
                 CorrelationQuery correlationQuery = ContractInferenceHelper.CreateServerCorrelationQuery(select, receive.CorrelationInitializers, info.OperationDescription, false);
                 this.CollectCorrelationQuery(ref queries, serviceContractXName, correlationQuery);
             }
             if (receive.HasReply)
             {
                 foreach (SendReply reply in receive.FollowingReplies)
                 {
                     ReceiveAndReplyTuple tuple2 = new ReceiveAndReplyTuple(receive, reply);
                     this.receiveAndReplyPairs.Remove(tuple2);
                     this.CollectCorrelationQueryFromReply(ref queries, serviceContractXName, reply, info.OperationDescription);
                     reply.SetContractName(serviceContractXName);
                 }
             }
             if (receive.HasFault)
             {
                 foreach (Activity activity in receive.FollowingFaults)
                 {
                     ReceiveAndReplyTuple tuple3 = new ReceiveAndReplyTuple(receive, activity);
                     this.receiveAndReplyPairs.Remove(tuple3);
                     this.CollectCorrelationQueryFromReply(ref queries, serviceContractXName, activity, info.OperationDescription);
                 }
             }
         }
         if (this.receiveAndReplyPairs.Count != 0)
         {
             throw System.ServiceModel.Activities.FxTrace.Exception.AsError(new ValidationException(System.ServiceModel.Activities.SR.DanglingReceive));
         }
         if (System.ServiceModel.Activities.TD.InferredContractDescriptionIsEnabled())
         {
             foreach (ContractDescription description3 in dictionary.Values)
             {
                 System.ServiceModel.Activities.TD.InferredContractDescription(description3.Name, description3.Namespace);
                 if (System.ServiceModel.Activities.TD.InferredOperationDescriptionIsEnabled())
                 {
                     foreach (OperationDescription description4 in description3.Operations)
                     {
                         System.ServiceModel.Activities.TD.InferredOperationDescription(description4.Name, description3.Name, description4.IsOneWay.ToString());
                     }
                 }
             }
         }
         this.cachedInferredContracts = dictionary;
     }
     return this.cachedInferredContracts;
 }
コード例 #2
0
 internal IDictionary <XName, ContractDescription> GetContractDescriptions()
 {
     if (this.cachedInferredContracts == null)
     {
         this.WalkActivityTree();
         this.correlationQueryByContract = new Dictionary <XName, Collection <CorrelationQuery> >();
         IDictionary <XName, ContractDescription> dictionary = new Dictionary <XName, ContractDescription>();
         IDictionary <ContractAndOperationNameTuple, OperationInfo> dictionary2 = new Dictionary <ContractAndOperationNameTuple, OperationInfo>();
         foreach (Receive receive in this.knownServiceActivities)
         {
             OperationInfo info;
             XName         serviceContractXName = this.FixServiceContractName(receive.ServiceContractName);
             ContractAndOperationNameTuple key  = new ContractAndOperationNameTuple(serviceContractXName, receive.OperationName);
             if (dictionary2.TryGetValue(key, out info))
             {
                 ContractValidationHelper.ValidateReceiveWithReceive(receive, info.Receive);
             }
             else
             {
                 ContractDescription description;
                 if (!dictionary.TryGetValue(serviceContractXName, out description))
                 {
                     description = new ContractDescription(serviceContractXName.LocalName, serviceContractXName.NamespaceName)
                     {
                         ConfigurationName = serviceContractXName.LocalName
                     };
                     dictionary.Add(serviceContractXName, description);
                 }
                 OperationDescription item = ContractInferenceHelper.CreateOperationDescription(receive, description);
                 description.Operations.Add(item);
                 info = new OperationInfo(receive, item);
                 dictionary2.Add(key, info);
             }
             this.CorrectOutMessageForOperationWithFault(receive, info);
             ContractInferenceHelper.UpdateIsOneWayFlag(receive, info.OperationDescription);
             ContractInferenceHelper.AddFaultDescription(receive, info.OperationDescription);
             ContractInferenceHelper.AddKnownTypesToOperation(receive, info.OperationDescription);
             ContractInferenceHelper.AddReceiveToFormatterBehavior(receive, info.OperationDescription);
             Collection <CorrelationQuery> queries = null;
             if (receive.HasCorrelatesOn || receive.HasCorrelationInitializers)
             {
                 MessageQuerySet  select           = receive.HasCorrelatesOn ? receive.CorrelatesOn : null;
                 CorrelationQuery correlationQuery = ContractInferenceHelper.CreateServerCorrelationQuery(select, receive.CorrelationInitializers, info.OperationDescription, false);
                 this.CollectCorrelationQuery(ref queries, serviceContractXName, correlationQuery);
             }
             if (receive.HasReply)
             {
                 foreach (SendReply reply in receive.FollowingReplies)
                 {
                     ReceiveAndReplyTuple tuple2 = new ReceiveAndReplyTuple(receive, reply);
                     this.receiveAndReplyPairs.Remove(tuple2);
                     this.CollectCorrelationQueryFromReply(ref queries, serviceContractXName, reply, info.OperationDescription);
                     reply.SetContractName(serviceContractXName);
                 }
             }
             if (receive.HasFault)
             {
                 foreach (Activity activity in receive.FollowingFaults)
                 {
                     ReceiveAndReplyTuple tuple3 = new ReceiveAndReplyTuple(receive, activity);
                     this.receiveAndReplyPairs.Remove(tuple3);
                     this.CollectCorrelationQueryFromReply(ref queries, serviceContractXName, activity, info.OperationDescription);
                 }
             }
         }
         if (this.receiveAndReplyPairs.Count != 0)
         {
             throw System.ServiceModel.Activities.FxTrace.Exception.AsError(new ValidationException(System.ServiceModel.Activities.SR.DanglingReceive));
         }
         if (System.ServiceModel.Activities.TD.InferredContractDescriptionIsEnabled())
         {
             foreach (ContractDescription description3 in dictionary.Values)
             {
                 System.ServiceModel.Activities.TD.InferredContractDescription(description3.Name, description3.Namespace);
                 if (System.ServiceModel.Activities.TD.InferredOperationDescriptionIsEnabled())
                 {
                     foreach (OperationDescription description4 in description3.Operations)
                     {
                         System.ServiceModel.Activities.TD.InferredOperationDescription(description4.Name, description3.Name, description4.IsOneWay.ToString());
                     }
                 }
             }
         }
         this.cachedInferredContracts = dictionary;
     }
     return(this.cachedInferredContracts);
 }