public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher) { this.ChannelDispatcher = endpointDispatcher.ChannelDispatcher; this.ChannelDispatcher.ChannelInitializers.Add(this); endpointDispatcher.DispatchRuntime.InputSessionShutdownHandlers.Add(this); endpointDispatcher.DispatchRuntime.AutomaticInputSessionShutdown = false; if (endpointDispatcher.DispatchRuntime.ImpersonateCallerForAllOperations) { this.ImpersonationRequired = true; } else if (AspNetEnvironment.Current.AspNetCompatibilityEnabled) { this.ImpersonationRequired = true; } BindingParameterCollection bindingParams = new BindingParameterCollection(); if (RoutingUtilities.IsTransactedReceive(endpoint.Binding, bindingParams)) { foreach (OperationDescription operation in endpoint.Contract.Operations) { if (operation.Behaviors.Find <TransactedReceiveOperationBehavior>() == null) { operation.Behaviors.Add(new TransactedReceiveOperationBehavior()); } } this.ChannelDispatcher.IsTransactedReceive = true; endpointDispatcher.DispatchRuntime.TransactionAutoCompleteOnSessionClose = true; this.TransactedReceiveEnabled = true; } IReceiveContextSettings rcSettings = endpoint.Binding.GetProperty <IReceiveContextSettings>(bindingParams); if (rcSettings != null && rcSettings.Enabled) { foreach (OperationDescription operation in endpoint.Contract.Operations) { ReceiveContextEnabledAttribute rcEnabled = new ReceiveContextEnabledAttribute(); rcEnabled.ManualControl = true; operation.Behaviors.Add(rcEnabled); } this.ReceiveContextEnabled = true; //Switch TransactedReceive off, because we don't want the Dispatcher creating any Transaction endpointDispatcher.ChannelDispatcher.IsTransactedReceive = false; endpointDispatcher.DispatchRuntime.TransactionAutoCompleteOnSessionClose = false; } }
public void Validate(System.ServiceModel.Description.ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { foreach (ServiceEndpoint endpoint in serviceDescription.Endpoints) { if (IsWorkflowEndpoint(endpoint)) { foreach (OperationDescription description in endpoint.Contract.Operations) { ReceiveContextEnabledAttribute attribute = description.Behaviors.Find <ReceiveContextEnabledAttribute>(); if ((attribute == null) || !attribute.ManualControl) { throw FxTrace.Exception.AsError(new InvalidOperationException(System.ServiceModel.Activities.SR.BufferedReceiveRequiresReceiveContext(description.Name))); } } } } }
public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { // Validate that ReceiveContext.ManualControl is set for each operation foreach (ServiceEndpoint serviceEndpoint in serviceDescription.Endpoints) { if (BufferedReceiveServiceBehavior.IsWorkflowEndpoint(serviceEndpoint)) { foreach (OperationDescription operation in serviceEndpoint.Contract.Operations) { ReceiveContextEnabledAttribute receiveContextEnabled = operation.Behaviors.Find <ReceiveContextEnabledAttribute>(); if (receiveContextEnabled == null || !receiveContextEnabled.ManualControl) { throw FxTrace.Exception.AsError( new InvalidOperationException(SR.BufferedReceiveRequiresReceiveContext(operation.Name))); } } } } }
void SetupReceiveContextEnabledAttribute(ServiceEndpoint serviceEndpoint) { if (BufferedReceiveServiceBehavior.IsWorkflowEndpoint(serviceEndpoint)) { foreach (OperationDescription operation in serviceEndpoint.Contract.Operations) { ReceiveContextEnabledAttribute behavior = operation.Behaviors.Find <ReceiveContextEnabledAttribute>(); if (behavior == null) { operation.Behaviors.Add(new ReceiveContextEnabledAttribute() { ManualControl = true }); } else { behavior.ManualControl = true; } } } }
private void SetupReceiveContextEnabledAttribute(ServiceEndpoint serviceEndpoint) { if (BufferedReceiveServiceBehavior.IsWorkflowEndpoint(serviceEndpoint)) { foreach (OperationDescription description in serviceEndpoint.Contract.Operations) { ReceiveContextEnabledAttribute attribute = description.Behaviors.Find <ReceiveContextEnabledAttribute>(); if (attribute == null) { ReceiveContextEnabledAttribute item = new ReceiveContextEnabledAttribute { ManualControl = true }; description.Behaviors.Add(item); } else { attribute.ManualControl = true; } } } }