protected override void CacheMetadata(ActivityMetadata metadata) { if (this.Request == null) { metadata.AddValidationError(System.ServiceModel.Activities.SR.SendReplyRequestCannotBeNull(base.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.internalSend = this.CreateInternalSend(); this.InternalContent.ConfigureInternalSendReply(this.internalSend, out this.responseFormatter); InArgument <CorrelationHandle> replyHandleFromReceive = this.GetReplyHandleFromReceive(); if (replyHandleFromReceive != null) { InArgument <CorrelationHandle> binding = MessagingActivityHelper.CreateReplyCorrelatesWith(replyHandleFromReceive); RuntimeArgument argument4 = new RuntimeArgument("InternalSendCorrelatesWith", Constants.CorrelationHandleType, ArgumentDirection.In); metadata.Bind(binding, argument4); metadata.AddArgument(argument4); this.internalSend.CorrelatesWith = (InArgument <CorrelationHandle>)InArgument.CreateReference(binding, "InternalSendCorrelatesWith"); if (this.responseFormatter != null) { InArgument <CorrelationHandle> argument5 = MessagingActivityHelper.CreateReplyCorrelatesWith(replyHandleFromReceive); RuntimeArgument argument6 = new RuntimeArgument("ResponseFormatterCorrelatesWith", Constants.CorrelationHandleType, ArgumentDirection.In); metadata.Bind(argument5, argument6); metadata.AddArgument(argument6); this.responseFormatter.CorrelatesWith = (InArgument <CorrelationHandle>)InArgument.CreateReference(argument5, "ResponseFormatterCorrelatesWith"); } } } else { this.internalSend = null; this.responseFormatter = null; } metadata.SetImportedChildrenCollection(new Collection <Activity>()); }
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>()); }
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>()); }
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>()); }
protected override void CacheMetadata(ActivityMetadata metadata) { if (this.Request == null) { metadata.AddValidationError(SR.SendReplyRequestCannotBeNull(this.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.internalSend = CreateInternalSend(); this.InternalContent.ConfigureInternalSendReply(this.internalSend, out this.responseFormatter); InArgument<CorrelationHandle> requestReplyHandleFromReceive = GetReplyHandleFromReceive(); if (requestReplyHandleFromReceive != null) { InArgument<CorrelationHandle> internalSendCorrelatesWith = MessagingActivityHelper.CreateReplyCorrelatesWith(requestReplyHandleFromReceive); RuntimeArgument internalSendCorrelatesWithArgument = new RuntimeArgument("InternalSendCorrelatesWith", Constants.CorrelationHandleType, ArgumentDirection.In); metadata.Bind(internalSendCorrelatesWith, internalSendCorrelatesWithArgument); metadata.AddArgument(internalSendCorrelatesWithArgument); this.internalSend.CorrelatesWith = (InArgument<CorrelationHandle>)InArgument.CreateReference(internalSendCorrelatesWith, "InternalSendCorrelatesWith"); if (this.responseFormatter != null) { InArgument<CorrelationHandle> responseFormatterCorrelatesWith = MessagingActivityHelper.CreateReplyCorrelatesWith(requestReplyHandleFromReceive); RuntimeArgument responseFormatterCorrelatesWithArgument = new RuntimeArgument("ResponseFormatterCorrelatesWith", Constants.CorrelationHandleType, ArgumentDirection.In); metadata.Bind(responseFormatterCorrelatesWith, responseFormatterCorrelatesWithArgument); metadata.AddArgument(responseFormatterCorrelatesWithArgument); responseFormatter.CorrelatesWith = (InArgument<CorrelationHandle>)InArgument.CreateReference(responseFormatterCorrelatesWith, "ResponseFormatterCorrelatesWith"); } } } else { this.internalSend = null; this.responseFormatter = null; } // We don't have any imported children despite referencing the Request metadata.SetImportedChildrenCollection(new Collection<Activity>()); }
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>()); }
protected override void CacheMetadata(ActivityMetadata metadata) { if (this.Request == null) { metadata.AddValidationError(SR.SendReplyRequestCannotBeNull(this.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.internalSend = CreateInternalSend(); this.InternalContent.ConfigureInternalSendReply(this.internalSend, out this.responseFormatter); InArgument <CorrelationHandle> requestReplyHandleFromReceive = GetReplyHandleFromReceive(); if (requestReplyHandleFromReceive != null) { InArgument <CorrelationHandle> internalSendCorrelatesWith = MessagingActivityHelper.CreateReplyCorrelatesWith(requestReplyHandleFromReceive); RuntimeArgument internalSendCorrelatesWithArgument = new RuntimeArgument("InternalSendCorrelatesWith", Constants.CorrelationHandleType, ArgumentDirection.In); metadata.Bind(internalSendCorrelatesWith, internalSendCorrelatesWithArgument); metadata.AddArgument(internalSendCorrelatesWithArgument); this.internalSend.CorrelatesWith = (InArgument <CorrelationHandle>)InArgument.CreateReference(internalSendCorrelatesWith, "InternalSendCorrelatesWith"); if (this.responseFormatter != null) { InArgument <CorrelationHandle> responseFormatterCorrelatesWith = MessagingActivityHelper.CreateReplyCorrelatesWith(requestReplyHandleFromReceive); RuntimeArgument responseFormatterCorrelatesWithArgument = new RuntimeArgument("ResponseFormatterCorrelatesWith", Constants.CorrelationHandleType, ArgumentDirection.In); metadata.Bind(responseFormatterCorrelatesWith, responseFormatterCorrelatesWithArgument); metadata.AddArgument(responseFormatterCorrelatesWithArgument); responseFormatter.CorrelatesWith = (InArgument <CorrelationHandle>)InArgument.CreateReference(responseFormatterCorrelatesWith, "ResponseFormatterCorrelatesWith"); } } } else { this.internalSend = null; this.responseFormatter = null; } // We don't have any imported children despite referencing the Request metadata.SetImportedChildrenCollection(new Collection <Activity>()); }