예제 #1
0
        void InitializeDescription(WorkflowService serviceDefinition, UriSchemeKeyedCollection baseAddresses)
        {
            Fx.Assert(serviceDefinition != null, "caller must verify");

            this.serviceDefinition = serviceDefinition;
            base.InitializeDescription(baseAddresses);

            foreach (Endpoint endpoint in serviceDefinition.Endpoints)
            {
                if (endpoint.Binding == null)
                {
                    string endpointName = ContractValidationHelper.GetErrorMessageEndpointName(endpoint.Name);
                    string contractName = ContractValidationHelper.GetErrorMessageEndpointServiceContractName(endpoint.ServiceContractName);
                    throw FxTrace.Exception.AsError(new InvalidOperationException(SR.MissingBindingInEndpoint(endpointName, contractName)));
                }

                ServiceEndpoint serviceEndpoint = AddServiceEndpointCore(endpoint.ServiceContractName, endpoint.Binding,
                                                                         endpoint.GetAddress(this), endpoint.ListenUri, endpoint.BehaviorConfigurationName);

                if (!string.IsNullOrEmpty(endpoint.Name))
                {
                    serviceEndpoint.Name = endpoint.Name;
                }
                serviceEndpoint.UnresolvedAddress   = endpoint.AddressUri;
                serviceEndpoint.UnresolvedListenUri = endpoint.ListenUri;
            }

            this.PersistTimeout      = defaultPersistTimeout;
            this.TrackTimeout        = defaultTrackTimeout;
            this.FilterResumeTimeout = defaultFilterResumeTimeout;
        }
예제 #2
0
        internal override void ValidateContract(NativeActivityContext context, OperationDescription targetOperation, object owner, MessageDirection direction)
        {
            MessageDescription targetMessage;
            string             overridingAction;
            bool             isResponse;
            SerializerOption serializerOption;

            if (direction == MessageDirection.Input)
            {
                Fx.Assert(targetOperation.Messages.Count >= 1, "There must be at least one MessageDescription in an OperationDescription!");
                targetMessage = targetOperation.Messages[0];

                Send send = owner as Send;
                Fx.Assert(send != null, "The parent of a SendMessageContent with in-message can only be Send!");

                overridingAction = send.Action;
                serializerOption = send.SerializerOption;

                isResponse = false;
            }
            else
            {
                Fx.Assert(targetOperation.Messages.Count == 2, "There must be exactly two MessageDescription objects for a two-way operation!");
                targetMessage = targetOperation.Messages[1];

                SendReply sendReply = owner as SendReply;
                Fx.Assert(sendReply != null, "The parent of a SendMessageContent with out-message can only be SendReply!");
                Fx.Assert(sendReply.Request != null, "SendReply.Request should not be null by now!");
                overridingAction = sendReply.Action;
                serializerOption = sendReply.Request.SerializerOption;

                isResponse = true;
            }

            if (!this.IsFault)
            {
                ContractValidationHelper.ValidateAction(context, targetMessage, overridingAction, targetOperation, isResponse);
                if (ContractValidationHelper.IsSendParameterContent(targetOperation))
                {
                    Constraint.AddValidationError(context, new ValidationError(SR.MisuseOfMessageContent(targetOperation.Name, targetOperation.DeclaringContract.Name)));
                }
                else
                {
                    ContractValidationHelper.ValidateMessageContent(context, targetMessage, this.InternalDeclaredMessageType,
                                                                    serializerOption, targetOperation, isResponse);
                }
            }
            else
            {
                Fx.Assert(this.InternalDeclaredMessageType != null, "IsFault returns true only when argument is of exception type!");
                Type argumentType = this.InternalDeclaredMessageType;

                if (argumentType.IsGenericType && argumentType.GetGenericTypeDefinition() == ContractInferenceHelper.FaultExceptionType)
                {
                    Type faultType = argumentType.GetGenericArguments()[0];
                    ContractValidationHelper.ValidateFault(context, targetOperation, overridingAction, faultType);
                }
            }
        }
예제 #3
0
        internal override void ValidateContract(NativeActivityContext context, OperationDescription targetOperation, object owner, MessageDirection direction)
        {
            MessageDescription targetMessage;
            string             overridingAction;
            bool isResponse;

            if (direction == MessageDirection.Input)
            {
                Fx.Assert(targetOperation.Messages.Count >= 1, "There must be at least one MessageDescription in an OperationDescription!");
                targetMessage = targetOperation.Messages[0];

                Fx.Assert(owner is Send, "The parent of a SendParametersContent with in-message can only be Send!");
                overridingAction = ((Send)owner).Action;

                isResponse = false;
            }
            else
            {
                Fx.Assert(targetOperation.Messages.Count == 2, "There must be exactly two MessageDescription objects for a two-way operation!");
                targetMessage = targetOperation.Messages[1];

                Fx.Assert(owner is SendReply, "The parent of a SendParametersContent with out-message can only be SendReply!");
                overridingAction = ((SendReply)owner).Action;

                isResponse = true;
            }

            if (!this.IsFault)
            {
                ContractValidationHelper.ValidateAction(context, targetMessage, overridingAction, targetOperation, isResponse);
                if (ContractValidationHelper.IsSendParameterContent(targetOperation))
                {
                    ContractValidationHelper.ValidateParametersContent(context, targetMessage, (IDictionary)this.Parameters, targetOperation, isResponse);
                }
                else
                {
                    Constraint.AddValidationError(context, new ValidationError(SR.MisuseOfParameterContent(targetOperation.Name, targetOperation.DeclaringContract.Name)));
                }
            }
            else
            {
                Fx.Assert(this.argumentTypes != null && this.argumentTypes.Length == 1, "Exception should be the only parameter in SendFault!");
                Type argumentType = this.argumentTypes[0];

                if (argumentType.IsGenericType && argumentType.GetGenericTypeDefinition() == ContractInferenceHelper.FaultExceptionType)
                {
                    Type faultType = argumentType.GetGenericArguments()[0];
                    ContractValidationHelper.ValidateFault(context, targetOperation, overridingAction, faultType);
                }
            }
        }
 internal override void CacheMetadata(ActivityMetadata metadata, Activity owner, string operationName)
 {
     MessagingActivityHelper.FixMessageArgument(this.Message, ArgumentDirection.Out, metadata);
     if (this.DeclaredMessageType != null)
     {
         if ((this.Message == null) && (this.DeclaredMessageType != TypeHelper.VoidType))
         {
             string errorMessageOperationName = ContractValidationHelper.GetErrorMessageOperationName(operationName);
             metadata.AddValidationError(System.ServiceModel.Activities.SR.ValueCannotBeNull(owner.DisplayName, errorMessageOperationName));
         }
         else if ((this.Message != null) && !this.DeclaredMessageType.IsAssignableFrom(this.Message.ArgumentType))
         {
             string str2 = ContractValidationHelper.GetErrorMessageOperationName(operationName);
             metadata.AddValidationError(System.ServiceModel.Activities.SR.ValueArgumentTypeNotDerivedFromValueType(owner.DisplayName, str2));
         }
     }
 }
예제 #5
0
        internal override void ValidateContract(NativeActivityContext context, OperationDescription targetOperation, object owner, MessageDirection direction)
        {
            MessageDescription targetMessage;
            string             overridingAction;
            bool             isResponse;
            SerializerOption serializerOption;

            if (direction == MessageDirection.Input)
            {
                Fx.Assert(targetOperation.Messages.Count >= 1, "There must be at least one MessageDescription in an OperationDescription!");
                targetMessage = targetOperation.Messages[0];

                Receive receive = owner as Receive;
                Fx.Assert(receive != null, "The parent of a ReceiveMessageContent with in-message can only be Receive!");

                overridingAction = receive.Action;
                serializerOption = receive.SerializerOption;

                isResponse = false;
            }
            else
            {
                Fx.Assert(targetOperation.Messages.Count == 2, "There must be exactly two MessageDescription objects for a two-way operation!");
                targetMessage = targetOperation.Messages[1];

                ReceiveReply receiveReply = owner as ReceiveReply;
                Fx.Assert(receiveReply != null, "The parent of a ReceiveMessageContent with out-message can only be ReceiveReply!");
                Fx.Assert(receiveReply.Request != null, "ReceiveReply.Request should not be null by now!");
                overridingAction = receiveReply.Action;
                serializerOption = receiveReply.Request.SerializerOption;

                isResponse = true;
            }

            ContractValidationHelper.ValidateAction(context, targetMessage, overridingAction, targetOperation, isResponse);
            if (ContractValidationHelper.IsReceiveParameterContent(targetOperation))
            {
                Constraint.AddValidationError(context, new ValidationError(SR.MisuseOfMessageContent(targetOperation.Name, targetOperation.DeclaringContract.Name)));
            }
            else
            {
                ContractValidationHelper.ValidateMessageContent(context, targetMessage, this.InternalDeclaredMessageType,
                                                                serializerOption, targetOperation, isResponse);
            }
        }
예제 #6
0
        internal override void ValidateContract(NativeActivityContext context, OperationDescription targetOperation, object owner, MessageDirection direction)
        {
            MessageDescription targetMessage;
            string             overridingAction;
            bool isResponse;

            if (direction == MessageDirection.Input)
            {
                Fx.Assert(targetOperation.Messages.Count >= 1, "There must be at least one MessageDescription in an OperationDescription!");
                targetMessage = targetOperation.Messages[0];

                Fx.Assert(owner is Receive, "The parent of a ReceiveParametersContent with in-message can only be Receive!");
                overridingAction = ((Receive)owner).Action;

                isResponse = false;
            }
            else
            {
                Fx.Assert(targetOperation.Messages.Count == 2, "There must be exactly two MessageDescription objects for a two-way operation!");
                targetMessage = targetOperation.Messages[1];

                Fx.Assert(owner is ReceiveReply, "The parent of a ReceiveParametersContent with out-message can only be ReceiveReply!");
                overridingAction = ((ReceiveReply)owner).Action;

                isResponse = true;
            }

            ContractValidationHelper.ValidateAction(context, targetMessage, overridingAction, targetOperation, isResponse);
            if (ContractValidationHelper.IsReceiveParameterContent(targetOperation))
            {
                ContractValidationHelper.ValidateParametersContent(context, targetMessage, (IDictionary)this.Parameters, targetOperation, isResponse);
            }
            else
            {
                Constraint.AddValidationError(context, new ValidationError(SR.MisuseOfParameterContent(targetOperation.Name, targetOperation.DeclaringContract.Name)));
            }
        }
예제 #7
0
 protected override void CacheMetadata(ActivityMetadata metadata)
 {
     if (string.IsNullOrEmpty(this.OperationName))
     {
         metadata.AddValidationError(System.ServiceModel.Activities.SR.MissingOperationName(base.DisplayName));
     }
     if (this.ServiceContractName == null)
     {
         string errorMessageOperationName = ContractValidationHelper.GetErrorMessageOperationName(this.OperationName);
         metadata.AddValidationError(System.ServiceModel.Activities.SR.MissingServiceContractName(base.DisplayName, errorMessageOperationName));
     }
     if (this.Endpoint == null)
     {
         if (string.IsNullOrEmpty(this.EndpointConfigurationName))
         {
             metadata.AddValidationError(System.ServiceModel.Activities.SR.EndpointNotSet(base.DisplayName, this.OperationName));
         }
     }
     else
     {
         if (!string.IsNullOrEmpty(this.EndpointConfigurationName))
         {
             metadata.AddValidationError(System.ServiceModel.Activities.SR.EndpointIncorrectlySet(base.DisplayName, this.OperationName));
         }
         if (this.Endpoint.Binding == null)
         {
             metadata.AddValidationError(System.ServiceModel.Activities.SR.MissingBindingInEndpoint(this.Endpoint.Name, this.ServiceContractName));
         }
     }
     MessagingActivityHelper.ValidateCorrelationInitializer(metadata, this.correlationInitializers, false, base.DisplayName, this.OperationName);
     MessagingActivityHelper.AddRuntimeArgument(this.CorrelatesWith, "CorrelatesWith", System.ServiceModel.Activities.Constants.CorrelationHandleType, ArgumentDirection.In, metadata);
     MessagingActivityHelper.AddRuntimeArgument(this.EndpointAddress, "EndpointAddress", System.ServiceModel.Activities.Constants.UriType, ArgumentDirection.In, metadata);
     this.InternalContent.CacheMetadata(metadata, this, this.OperationName);
     if (this.correlationInitializers != null)
     {
         for (int i = 0; i < this.correlationInitializers.Count; i++)
         {
             CorrelationInitializer initializer = this.correlationInitializers[i];
             initializer.ArgumentName = "Parameter" + i;
             RuntimeArgument argument = new RuntimeArgument(initializer.ArgumentName, System.ServiceModel.Activities.Constants.CorrelationHandleType, ArgumentDirection.In);
             metadata.Bind(initializer.CorrelationHandle, argument);
             metadata.AddArgument(argument);
         }
     }
     if (!metadata.HasViolations)
     {
         if ((this.InternalContent is SendMessageContent) && MessageBuilder.IsMessageContract(((SendMessageContent)this.InternalContent).InternalDeclaredMessageType))
         {
             this.OperationUsesMessageContract = true;
         }
         this.internalSend = this.CreateInternalSend();
         this.InternalContent.ConfigureInternalSend(this.internalSend, out this.requestFormatter);
         if ((this.requestFormatter != null) && (this.lazyFormatter != null))
         {
             this.requestFormatter.Formatter = this.lazyFormatter;
         }
     }
     else
     {
         this.internalSend     = null;
         this.requestFormatter = null;
     }
 }
예제 #8
0
        protected override void CacheMetadata(ActivityMetadata metadata)
        {
            if (this.Request == null)
            {
                metadata.AddValidationError(SR.ReceiveReplyRequestCannotBeNull(this.DisplayName));
            }
            else
            {
                // Need to validate Send.ServiceContractName and Send.OperationName here so that we can proceed with contract inference
                if (this.Request.ServiceContractName == null)
                {
                    string errorOperationName = ContractValidationHelper.GetErrorMessageOperationName(this.Request.OperationName);
                    metadata.AddValidationError(SR.MissingServiceContractName(this.Request.DisplayName, errorOperationName));
                }
                if (string.IsNullOrEmpty(this.Request.OperationName))
                {
                    metadata.AddValidationError(SR.MissingOperationName(this.Request.DisplayName));
                }
            }

            // validate Correlation Initializers
            MessagingActivityHelper.ValidateCorrelationInitializer(metadata, this.correlationInitializers, true, this.DisplayName, (this.Request != null ? this.Request.OperationName : String.Empty));

            // Validate Content
            string operationName = this.Request != null ? this.Request.OperationName : null;

            this.InternalContent.CacheMetadata(metadata, this, operationName);

            if (this.correlationInitializers != null)
            {
                for (int i = 0; i < this.correlationInitializers.Count; i++)
                {
                    CorrelationInitializer initializer = this.correlationInitializers[i];
                    initializer.ArgumentName = Constants.Parameter + i;
                    RuntimeArgument initializerArgument = new RuntimeArgument(initializer.ArgumentName, Constants.CorrelationHandleType, ArgumentDirection.In);
                    metadata.Bind(initializer.CorrelationHandle, initializerArgument);
                    metadata.AddArgument(initializerArgument);
                }
            }

            if (!metadata.HasViolations)
            {
                this.internalReceive = CreateInternalReceive();

                InArgument <CorrelationHandle> requestReplyHandleFromSend = GetReplyHandleFromSend();
                if (requestReplyHandleFromSend != null)
                {
                    InArgument <CorrelationHandle> resultCorrelatesWith = MessagingActivityHelper.CreateReplyCorrelatesWith(requestReplyHandleFromSend);

                    RuntimeArgument resultCorrelatesWithArgument = new RuntimeArgument("ResultCorrelatesWith", Constants.CorrelationHandleType, ArgumentDirection.In);
                    metadata.Bind(resultCorrelatesWith, resultCorrelatesWithArgument);
                    metadata.AddArgument(resultCorrelatesWithArgument);

                    this.internalReceive.CorrelatesWith = (InArgument <CorrelationHandle>)InArgument.CreateReference(resultCorrelatesWith, "ResultCorrelatesWith");
                }

                this.InternalContent.ConfigureInternalReceiveReply(this.internalReceive, out this.responseFormatter);

                if (this.InternalContent is ReceiveMessageContent &&
                    MessageBuilder.IsMessageContract(((ReceiveMessageContent)this.InternalContent).InternalDeclaredMessageType))
                {
                    this.Request.OperationUsesMessageContract = true;
                }

                OperationDescription operation = ContractInferenceHelper.CreateTwoWayOperationDescription(this.Request, this);
                this.Request.OperationDescription = operation;

                if (this.responseFormatter != null)
                {
                    IClientMessageFormatter formatter = ClientOperationFormatterProvider.GetFormatterFromRuntime(operation);

                    this.Request.SetFormatter(formatter);
                    this.responseFormatter.Formatter = formatter;

                    //
                    int    index      = 0;
                    Type[] faultTypes = new Type[operation.KnownTypes.Count];
                    foreach (Type type in operation.KnownTypes)
                    {
                        faultTypes[index] = type;
                        index++;
                    }

                    this.responseFormatter.FaultFormatter = new FaultFormatter(faultTypes);
                }

                // Add CorrelationQuery to the Send->ReplyCorrelation, we validate that the same query is not added multiple times
                if (this.correlationInitializers != null && this.correlationInitializers.Count > 0)
                {
                    Collection <CorrelationQuery> internalCorrelationQueryCollection = ContractInferenceHelper.CreateClientCorrelationQueries(null, this.correlationInitializers,
                                                                                                                                              this.Action, this.Request.ServiceContractName, this.Request.OperationName, true);

                    foreach (CorrelationQuery query in internalCorrelationQueryCollection)
                    {
                        this.Request.SetReplyCorrelationQuery(query);
                    }
                }
            }
            else
            {
                this.internalReceive   = null;
                this.responseFormatter = null;
            }

            // We don't have any imported children despite referencing the Request
            metadata.SetImportedChildrenCollection(new Collection <Activity>());
        }
예제 #9
0
        protected override void CacheMetadata(ActivityMetadata metadata)
        {
            if (this.Request == null)
            {
                metadata.AddValidationError(System.ServiceModel.Activities.SR.ReceiveReplyRequestCannotBeNull(base.DisplayName));
            }
            else
            {
                if (this.Request.ServiceContractName == null)
                {
                    string errorMessageOperationName = ContractValidationHelper.GetErrorMessageOperationName(this.Request.OperationName);
                    metadata.AddValidationError(System.ServiceModel.Activities.SR.MissingServiceContractName(this.Request.DisplayName, errorMessageOperationName));
                }
                if (string.IsNullOrEmpty(this.Request.OperationName))
                {
                    metadata.AddValidationError(System.ServiceModel.Activities.SR.MissingOperationName(this.Request.DisplayName));
                }
            }
            MessagingActivityHelper.ValidateCorrelationInitializer(metadata, this.correlationInitializers, true, base.DisplayName, (this.Request != null) ? this.Request.OperationName : string.Empty);
            string operationName = (this.Request != null) ? this.Request.OperationName : null;

            this.InternalContent.CacheMetadata(metadata, this, operationName);
            if (this.correlationInitializers != null)
            {
                for (int i = 0; i < this.correlationInitializers.Count; i++)
                {
                    CorrelationInitializer initializer = this.correlationInitializers[i];
                    initializer.ArgumentName = "Parameter" + i;
                    RuntimeArgument argument = new RuntimeArgument(initializer.ArgumentName, Constants.CorrelationHandleType, ArgumentDirection.In);
                    metadata.Bind(initializer.CorrelationHandle, argument);
                    metadata.AddArgument(argument);
                }
            }
            if (!metadata.HasViolations)
            {
                this.internalReceive = this.CreateInternalReceive();
                InArgument <CorrelationHandle> replyHandleFromSend = this.GetReplyHandleFromSend();
                if (replyHandleFromSend != null)
                {
                    InArgument <CorrelationHandle> binding = MessagingActivityHelper.CreateReplyCorrelatesWith(replyHandleFromSend);
                    RuntimeArgument argument4 = new RuntimeArgument("ResultCorrelatesWith", Constants.CorrelationHandleType, ArgumentDirection.In);
                    metadata.Bind(binding, argument4);
                    metadata.AddArgument(argument4);
                    this.internalReceive.CorrelatesWith = (InArgument <CorrelationHandle>)InArgument.CreateReference(binding, "ResultCorrelatesWith");
                }
                this.InternalContent.ConfigureInternalReceiveReply(this.internalReceive, out this.responseFormatter);
                if ((this.InternalContent is ReceiveMessageContent) && MessageBuilder.IsMessageContract(((ReceiveMessageContent)this.InternalContent).InternalDeclaredMessageType))
                {
                    this.Request.OperationUsesMessageContract = true;
                }
                OperationDescription operationDescription = ContractInferenceHelper.CreateTwoWayOperationDescription(this.Request, this);
                this.Request.OperationDescription = operationDescription;
                if (this.responseFormatter != null)
                {
                    IClientMessageFormatter formatterFromRuntime = ClientOperationFormatterProvider.GetFormatterFromRuntime(operationDescription);
                    this.Request.SetFormatter(formatterFromRuntime);
                    this.responseFormatter.Formatter = formatterFromRuntime;
                    int    index       = 0;
                    Type[] detailTypes = new Type[operationDescription.KnownTypes.Count];
                    foreach (Type type in operationDescription.KnownTypes)
                    {
                        detailTypes[index] = type;
                        index++;
                    }
                    this.responseFormatter.FaultFormatter = new FaultFormatter(detailTypes);
                }
                if ((this.correlationInitializers != null) && (this.correlationInitializers.Count > 0))
                {
                    foreach (CorrelationQuery query in ContractInferenceHelper.CreateClientCorrelationQueries(null, this.correlationInitializers, this.Action, this.Request.ServiceContractName, this.Request.OperationName, true))
                    {
                        this.Request.SetReplyCorrelationQuery(query);
                    }
                }
            }
            else
            {
                this.internalReceive   = null;
                this.responseFormatter = null;
            }
            metadata.SetImportedChildrenCollection(new Collection <Activity>());
        }
예제 #10
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);
 }
예제 #11
0
 private void WalkActivityTree()
 {
     if (this.knownServiceActivities == null)
     {
         if (this.Body == null)
         {
             throw System.ServiceModel.Activities.FxTrace.Exception.AsError(new ValidationException(System.ServiceModel.Activities.SR.MissingBodyInWorkflowService));
         }
         WorkflowInspectionServices.CacheMetadata(this.Body);
         this.knownServiceActivities = new List <Receive>();
         this.receiveAndReplyPairs   = new HashSet <ReceiveAndReplyTuple>();
         Queue <QueueItem> queue = new Queue <QueueItem>();
         queue.Enqueue(new QueueItem(this.Body, null, null));
         while (queue.Count > 0)
         {
             QueueItem item     = queue.Dequeue();
             Activity  activity = item.Activity;
             TransactedReceiveScope parentTransactedReceiveScope = item.ParentTransactedReceiveScope;
             TransactedReceiveScope rootTransactedReceiveScope   = item.RootTransactedReceiveScope;
             if (activity is Receive)
             {
                 Receive receive = (Receive)activity;
                 if (rootTransactedReceiveScope != null)
                 {
                     receive.InternalReceive.AdditionalData.IsInsideTransactedReceiveScope = true;
                     if ((receive == parentTransactedReceiveScope.Request) && (parentTransactedReceiveScope == rootTransactedReceiveScope))
                     {
                         receive.InternalReceive.AdditionalData.IsFirstReceiveOfTransactedReceiveScopeTree = true;
                     }
                 }
                 this.knownServiceActivities.Add(receive);
             }
             else if (activity is SendReply)
             {
                 SendReply reply   = (SendReply)activity;
                 Receive   request = reply.Request;
                 if (reply.InternalContent.IsFault)
                 {
                     request.FollowingFaults.Add(reply);
                 }
                 else
                 {
                     if (request.HasReply)
                     {
                         SendReply reply2 = request.FollowingReplies[0];
                         ContractValidationHelper.ValidateSendReplyWithSendReply(reply2, reply);
                     }
                     request.FollowingReplies.Add(reply);
                 }
                 ReceiveAndReplyTuple tuple = new ReceiveAndReplyTuple(request, reply);
                 this.receiveAndReplyPairs.Add(tuple);
             }
             if (activity is TransactedReceiveScope)
             {
                 parentTransactedReceiveScope = activity as TransactedReceiveScope;
                 if (rootTransactedReceiveScope == null)
                 {
                     rootTransactedReceiveScope = parentTransactedReceiveScope;
                 }
             }
             foreach (Activity activity2 in WorkflowInspectionServices.GetActivities(activity))
             {
                 QueueItem item2 = new QueueItem(activity2, parentTransactedReceiveScope, rootTransactedReceiveScope);
                 queue.Enqueue(item2);
             }
         }
     }
 }