Пример #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
        protected override void CacheMetadata(ActivityMetadata metadata)
        {
            if (string.IsNullOrEmpty(this.OperationName))
            {
                metadata.AddValidationError(SR.MissingOperationName(this.DisplayName));
            }
            if (this.ServiceContractName == null)
            {
                string errorOperationName = ContractValidationHelper.GetErrorMessageOperationName(this.OperationName);
                metadata.AddValidationError(SR.MissingServiceContractName(this.DisplayName, errorOperationName));
            }

            if (this.Endpoint == null)
            {
                if (string.IsNullOrEmpty(this.EndpointConfigurationName))
                {
                    metadata.AddValidationError(SR.EndpointNotSet(this.DisplayName, this.OperationName));
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(this.EndpointConfigurationName))
                {
                    metadata.AddValidationError(SR.EndpointIncorrectlySet(this.DisplayName, this.OperationName));
                }
                if (this.Endpoint.Binding == null)
                {
                    metadata.AddValidationError(SR.MissingBindingInEndpoint(this.Endpoint.Name, this.ServiceContractName));
                }
            }

            // validate Correlation Initializers
            MessagingActivityHelper.ValidateCorrelationInitializer(metadata, this.correlationInitializers, false, this.DisplayName, this.OperationName);

            // Add runtime arguments
            MessagingActivityHelper.AddRuntimeArgument(this.CorrelatesWith, "CorrelatesWith", Constants.CorrelationHandleType, ArgumentDirection.In, metadata);
            MessagingActivityHelper.AddRuntimeArgument(this.EndpointAddress, "EndpointAddress", Constants.UriType, ArgumentDirection.In, metadata);

            // Validate Content
            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 = Constants.Parameter + i;
                    RuntimeArgument initializerArgument = new RuntimeArgument(initializer.ArgumentName, Constants.CorrelationHandleType, ArgumentDirection.In);
                    metadata.Bind(initializer.CorrelationHandle, initializerArgument);
                    metadata.AddArgument(initializerArgument);
                }
            }

            if (!metadata.HasViolations)
            {
                if (this.InternalContent is SendMessageContent &&
                    MessageBuilder.IsMessageContract(((SendMessageContent)this.InternalContent).InternalDeclaredMessageType))
                {
                    this.OperationUsesMessageContract = true;
                }

                this.internalSend = 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;
            }
        }