void IEndpointBehavior.ApplyClientBehavior(ServiceEndpoint serviceEndpoint, ClientRuntime clientRuntime) { if (!serviceEndpoint.Contract.IsDuplex()) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString( SR.SFxCallbackBehaviorAttributeOnlyOnDuplex, serviceEndpoint.Contract.Name))); } DispatchRuntime dispatchRuntime = clientRuntime.DispatchRuntime; dispatchRuntime.ValidateMustUnderstand = validateMustUnderstand; dispatchRuntime.ConcurrencyMode = this.concurrencyMode; dispatchRuntime.ChannelDispatcher.IncludeExceptionDetailInFaults = this.includeExceptionDetailInFaults; dispatchRuntime.AutomaticInputSessionShutdown = this.automaticSessionShutdown; if (!this.useSynchronizationContext) { dispatchRuntime.SynchronizationContext = null; } dispatchRuntime.ChannelDispatcher.TransactionTimeout = transactionTimeout; if (isolationLevelSet) { SetIsolationLevel(dispatchRuntime.ChannelDispatcher); } DataContractSerializerServiceBehavior.ApplySerializationSettings(serviceEndpoint, this.ignoreExtensionDataObject, this.maxItemsInObjectGraph); }
void IServiceBehavior.ApplyDispatchBehavior(ServiceDescription description, ServiceHostBase serviceHostBase) { for (int i = 0; i < serviceHostBase.ChannelDispatchers.Count; i++) { ChannelDispatcher channelDispatcher = serviceHostBase.ChannelDispatchers[i] as ChannelDispatcher; if (channelDispatcher != null) { channelDispatcher.IncludeExceptionDetailInFaults = this.includeExceptionDetailInFaults; if (channelDispatcher.HasApplicationEndpoints()) { channelDispatcher.TransactionTimeout = transactionTimeout; if (isolationLevelSet) { SetIsolationLevel(channelDispatcher); } foreach (EndpointDispatcher endpointDispatcher in channelDispatcher.Endpoints) { if (endpointDispatcher.IsSystemEndpoint) { continue; } DispatchRuntime behavior = endpointDispatcher.DispatchRuntime; behavior.ConcurrencyMode = this.concurrencyMode; behavior.EnsureOrderedDispatch = this.ensureOrderedDispatch; behavior.ValidateMustUnderstand = validateMustUnderstand; behavior.AutomaticInputSessionShutdown = this.automaticSessionShutdown; behavior.TransactionAutoCompleteOnSessionClose = this.transactionAutoCompleteOnSessionClose; behavior.ReleaseServiceInstanceOnTransactionComplete = this.releaseServiceInstanceOnTransactionComplete; if (!this.useSynchronizationContext) { behavior.SynchronizationContext = null; } if (!endpointDispatcher.AddressFilterSetExplicit) { EndpointAddress address = endpointDispatcher.OriginalAddress; if (address == null || this.AddressFilterMode == AddressFilterMode.Any) { endpointDispatcher.AddressFilter = new MatchAllMessageFilter(); } else if (this.AddressFilterMode == AddressFilterMode.Prefix) { endpointDispatcher.AddressFilter = new PrefixEndpointAddressMessageFilter(address); } else if (this.AddressFilterMode == AddressFilterMode.Exact) { endpointDispatcher.AddressFilter = new EndpointAddressMessageFilter(address); } } } } #pragma warning suppress 56506 } } DataContractSerializerServiceBehavior.ApplySerializationSettings(description, ignoreExtensionDataObject, maxItemsInObjectGraph); ApplyInstancing(description, serviceHostBase); }
void IServiceBehavior.ApplyDispatchBehavior(ServiceDescription description, ServiceHostBase serviceHostBase) { for (int index = 0; index < serviceHostBase.ChannelDispatchers.Count; ++index) { ChannelDispatcher channelDispatcher = serviceHostBase.ChannelDispatchers[index] as ChannelDispatcher; if (channelDispatcher != null) { channelDispatcher.IncludeExceptionDetailInFaults = this.includeExceptionDetailInFaults; if (channelDispatcher.HasApplicationEndpoints()) { channelDispatcher.TransactionTimeout = this.transactionTimeout; if (this.isolationLevelSet) { this.SetIsolationLevel(channelDispatcher); } foreach (EndpointDispatcher endpointDispatcher in channelDispatcher.Endpoints) { if (!endpointDispatcher.IsSystemEndpoint) { DispatchRuntime dispatchRuntime = endpointDispatcher.DispatchRuntime; dispatchRuntime.ConcurrencyMode = this.concurrencyMode; dispatchRuntime.ValidateMustUnderstand = this.validateMustUnderstand; dispatchRuntime.AutomaticInputSessionShutdown = this.automaticSessionShutdown; dispatchRuntime.TransactionAutoCompleteOnSessionClose = this.transactionAutoCompleteOnSessionClose; dispatchRuntime.ReleaseServiceInstanceOnTransactionComplete = this.releaseServiceInstanceOnTransactionComplete; if (!this.useSynchronizationContext) { dispatchRuntime.SynchronizationContext = (SynchronizationContext)null; } if (!endpointDispatcher.AddressFilterSetExplicit) { EndpointAddress originalAddress = endpointDispatcher.OriginalAddress; if (originalAddress == (EndpointAddress)null || this.AddressFilterMode == AddressFilterMode.Any) { endpointDispatcher.AddressFilter = (MessageFilter) new MatchAllMessageFilter(); } else if (this.AddressFilterMode == AddressFilterMode.Prefix) { endpointDispatcher.AddressFilter = (MessageFilter) new PrefixEndpointAddressMessageFilter(originalAddress); } else if (this.AddressFilterMode == AddressFilterMode.Exact) { endpointDispatcher.AddressFilter = (MessageFilter) new EndpointAddressMessageFilter(originalAddress); } } } } } } } DataContractSerializerServiceBehavior.ApplySerializationSettings(description, this.ignoreExtensionDataObject, this.maxItemsInObjectGraph); this.ApplyInstancing(description, serviceHostBase); }
void IServiceBehavior.ApplyDispatchBehavior(ServiceDescription description, ServiceHostBase serviceHostBase) { for (int i = 0; i < serviceHostBase.ChannelDispatchers.Count; i++) { ChannelDispatcher channelDispatcher = serviceHostBase.ChannelDispatchers[i] as ChannelDispatcher; if (channelDispatcher != null) { channelDispatcher.IncludeExceptionDetailInFaults = _includeExceptionDetailInFaults; if (channelDispatcher.HasApplicationEndpoints) { foreach (EndpointDispatcher endpointDispatcher in channelDispatcher.Endpoints) { if (endpointDispatcher.IsSystemEndpoint) { continue; } DispatchRuntime behavior = endpointDispatcher.DispatchRuntime; behavior.ConcurrencyMode = _concurrencyMode; behavior.EnsureOrderedDispatch = _ensureOrderedDispatch; behavior.ValidateMustUnderstand = _validateMustUnderstand; behavior.AutomaticInputSessionShutdown = _automaticSessionShutdown; if (!_useSynchronizationContext) { behavior.SynchronizationContext = null; } if (!endpointDispatcher.AddressFilterSetExplicit) { EndpointAddress address = endpointDispatcher.OriginalAddress; if (address == null || AddressFilterMode == AddressFilterMode.Any) { endpointDispatcher.AddressFilter = new MatchAllMessageFilter(); } else if (AddressFilterMode == AddressFilterMode.Prefix) { endpointDispatcher.AddressFilter = new PrefixEndpointAddressMessageFilter(address); } else if (AddressFilterMode == AddressFilterMode.Exact) { endpointDispatcher.AddressFilter = new EndpointAddressMessageFilter(address); } } } } } } DataContractSerializerServiceBehavior.ApplySerializationSettings(description, _ignoreExtensionDataObject, _maxItemsInObjectGraph); ApplyInstancing(description, serviceHostBase); }
public void ApplyDispatchBehavior(ServiceDescription description, ServiceHostBase serviceHostBase) { if (description == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("description"); } if (serviceHostBase == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serviceHostBase"); } if (description.Behaviors == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("description", SR2.GetString(SR2.NoBehaviors)); } if (description.Endpoints == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("description", SR2.GetString(SR2.NoEndpoints)); } bool syncContextRegistered = false; WorkflowRuntimeBehavior workflowRuntimeBehavior = description.Behaviors.Find <WorkflowRuntimeBehavior>(); if (workflowRuntimeBehavior == null) { workflowRuntimeBehavior = new WorkflowRuntimeBehavior(); description.Behaviors.Add(workflowRuntimeBehavior); } WorkflowPersistenceService persistenceService = workflowRuntimeBehavior.WorkflowRuntime.GetService <WorkflowPersistenceService>(); if (persistenceService != null) { bool wasRuntimeStarted = workflowRuntimeBehavior.WorkflowRuntime.IsStarted; if (wasRuntimeStarted) { workflowRuntimeBehavior.WorkflowRuntime.StopRuntime(); } workflowRuntimeBehavior.WorkflowRuntime.RemoveService(persistenceService); workflowRuntimeBehavior.WorkflowRuntime.AddService(new SkipUnloadOnFirstIdleWorkflowPersistenceService(persistenceService)); if (wasRuntimeStarted) { workflowRuntimeBehavior.WorkflowRuntime.StartRuntime(); } } this.workflowDefinitionContext.Register(workflowRuntimeBehavior.WorkflowRuntime, workflowRuntimeBehavior.ValidateOnCreate); WorkflowInstanceContextProvider instanceContextProvider = new WorkflowInstanceContextProvider( serviceHostBase, false, this.workflowDefinitionContext ); WorkflowInstanceContextProvider singleCallInstanceContextProvider = null; IInstanceProvider instanceProvider = new WorkflowInstanceProvider(instanceContextProvider); ServiceDebugBehavior serviceDebugBehavior = description.Behaviors.Find <ServiceDebugBehavior>(); bool includeExceptionDetailsInFaults = this.IncludeExceptionDetailInFaults; if (serviceDebugBehavior != null) { includeExceptionDetailsInFaults |= serviceDebugBehavior.IncludeExceptionDetailInFaults; } IErrorHandler workflowOperationErrorHandler = new WorkflowOperationErrorHandler(includeExceptionDetailsInFaults); foreach (ChannelDispatcherBase channelDispatcherBase in serviceHostBase.ChannelDispatchers) { ChannelDispatcher channelDispatcher = channelDispatcherBase as ChannelDispatcher; if (channelDispatcher != null && channelDispatcher.HasApplicationEndpoints()) { channelDispatcher.IncludeExceptionDetailInFaults = includeExceptionDetailsInFaults; channelDispatcher.ErrorHandlers.Add(workflowOperationErrorHandler); foreach (EndpointDispatcher endPointDispatcher in channelDispatcher.Endpoints) { if (endPointDispatcher.IsSystemEndpoint) { continue; } ServiceEndpoint serviceEndPoint = description.Endpoints.Find(new XmlQualifiedName(endPointDispatcher.ContractName, endPointDispatcher.ContractNamespace)); if (serviceEndPoint != null) { DispatchRuntime dispatchRuntime = endPointDispatcher.DispatchRuntime; dispatchRuntime.AutomaticInputSessionShutdown = true; dispatchRuntime.ConcurrencyMode = ConcurrencyMode.Single; dispatchRuntime.ValidateMustUnderstand = this.ValidateMustUnderstand; if (!this.UseSynchronizationContext) { dispatchRuntime.SynchronizationContext = null; } else if (!syncContextRegistered) { SynchronizationContextWorkflowSchedulerService syncSchedulerService = workflowRuntimeBehavior.WorkflowRuntime.GetService <SynchronizationContextWorkflowSchedulerService>(); Fx.Assert(syncSchedulerService != null, "Wrong Synchronization Context Set"); syncSchedulerService.SetSynchronizationContext(dispatchRuntime.SynchronizationContext); syncContextRegistered = true; } if (!endPointDispatcher.AddressFilterSetExplicit) { EndpointAddress endPointAddress = endPointDispatcher.OriginalAddress; if ((endPointAddress == null) || (this.AddressFilterMode == AddressFilterMode.Any)) { endPointDispatcher.AddressFilter = new MatchAllMessageFilter(); } else if (this.AddressFilterMode == AddressFilterMode.Prefix) { endPointDispatcher.AddressFilter = new PrefixEndpointAddressMessageFilter(endPointAddress); } else if (this.AddressFilterMode == AddressFilterMode.Exact) { endPointDispatcher.AddressFilter = new EndpointAddressMessageFilter(endPointAddress); } } if (serviceEndPoint.Contract.SessionMode != SessionMode.NotAllowed) { endPointDispatcher.DispatchRuntime.InstanceContextProvider = instanceContextProvider; } else { if (singleCallInstanceContextProvider == null) { singleCallInstanceContextProvider = new WorkflowInstanceContextProvider( serviceHostBase, true, this.workflowDefinitionContext); } endPointDispatcher.DispatchRuntime.InstanceContextProvider = singleCallInstanceContextProvider; } endPointDispatcher.DispatchRuntime.MessageInspectors.Add(new DurableMessageDispatchInspector(serviceEndPoint.Contract.SessionMode)); endPointDispatcher.DispatchRuntime.InstanceProvider = instanceProvider; SetContractFilterToIncludeAllOperations(endPointDispatcher, serviceEndPoint.Contract); } } } } DataContractSerializerServiceBehavior.ApplySerializationSettings(description, this.ignoreExtensionDataObject, this.maxItemsInObjectGraph); }