/// <summary>Provides the ability to change run-time property values or insert custom extension objects such as error handlers, message or parameter interceptors, security extensions, and other custom extension objects.</summary> /// <param name="serviceDescription">The service description.</param> /// <param name="serviceHostBase">The host that is currently being built.</param> public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { if (serviceDescription == null) { throw new ArgumentNullException(nameof(serviceDescription)); } if (serviceHostBase == null) { throw new ArgumentNullException(nameof(serviceHostBase)); } for (var dispatcherIndex = 0; dispatcherIndex < serviceHostBase.ChannelDispatchers.Count; dispatcherIndex++) { ChannelDispatcherBase dispatcher = serviceHostBase.ChannelDispatchers[dispatcherIndex]; ChannelDispatcher channelDispatcher = (ChannelDispatcher)dispatcher; for (var endpointIndex = 0; endpointIndex < channelDispatcher.Endpoints.Count; endpointIndex++) { EndpointDispatcher endpointDispatcher = channelDispatcher.Endpoints[endpointIndex]; endpointDispatcher.DispatchRuntime.InstanceProvider = new GraceInstanceProvider(_locator, serviceDescription.ServiceType); } } }
/// <summary> /// Provides the ability to change run-time property values or insert custom extension objects such as error handlers, message or parameter interceptors, /// security extensions, and other custom extension objects. /// </summary> /// <param name="serviceDescription"> /// The service description. /// </param> /// <param name="serviceHostBase"> /// The host that is currently being built. /// </param> /// <exception cref="ArgumentNullException"> /// The <paramref name="serviceDescription"/> value is <c>null</c>. /// </exception> /// <exception cref="ArgumentNullException"> /// The <paramref name="serviceHostBase"/> value is <c>null</c>. /// </exception> public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { if (serviceDescription == null) { throw new ArgumentNullException(nameof(serviceDescription)); } if (serviceDescription.ServiceType == null) { throw new ArgumentNullException($"{nameof(serviceDescription)}.{nameof(ServiceDescription.ServiceType)}"); } if (serviceHostBase == null) { throw new ArgumentNullException(nameof(serviceHostBase)); } for (int dispatcherIndex = 0; dispatcherIndex < serviceHostBase.ChannelDispatchers.Count; dispatcherIndex++) { ChannelDispatcherBase dispatcher = serviceHostBase.ChannelDispatchers[dispatcherIndex]; ChannelDispatcher channelDispatcher = (ChannelDispatcher)dispatcher; for (int endpointIndex = 0; endpointIndex < channelDispatcher.Endpoints.Count; endpointIndex++) { EndpointDispatcher endpointDispatcher = channelDispatcher.Endpoints[endpointIndex]; endpointDispatcher.DispatchRuntime.InstanceProvider = new UnityInstanceProvider(this.Container, serviceDescription.ServiceType, this.ResolveName); } } }
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { if (serviceDescription == null) { throw new ArgumentNullException("serviceDescription"); } if (serviceHostBase == null) { throw new ArgumentNullException("serviceHostBase"); } for (Int32 dispatcherIndex = 0; dispatcherIndex < serviceHostBase.ChannelDispatchers.Count; dispatcherIndex++) { ChannelDispatcherBase dispatcher = serviceHostBase.ChannelDispatchers[dispatcherIndex]; ChannelDispatcher channelDispatcher = (ChannelDispatcher)dispatcher; for (Int32 endpointIndex = 0; endpointIndex < channelDispatcher.Endpoints.Count; endpointIndex++) { EndpointDispatcher endpointDispatcher = channelDispatcher.Endpoints[endpointIndex]; endpointDispatcher.DispatchRuntime.InstanceProvider = new UnityInstanceProvider(Container, serviceDescription.ServiceType); } } }
internal void OnRemoveChannelDispatcher(ChannelDispatcherBase channelDispatcher) { lock (ThisLock) { ThrowIfClosedOrOpened(); channelDispatcher.DetachInternal(this); } }
// Configuration //protected void LoadConfigurationSection(ServiceElement serviceSection) //{ // throw new PlatformNotSupportedException(); //} internal void OnAddChannelDispatcher(ChannelDispatcherBase channelDispatcher) { lock (ThisLock) { ThrowIfClosedOrOpened(); channelDispatcher.AttachInternal(this); channelDispatcher.Faulted += new EventHandler(OnChannelDispatcherFaulted); } }
public ChannelDispatcherModel(ChannelDispatcherBase channelDispatcher) { if (channelDispatcher == null) { return; } IChannelListener listener = channelDispatcher?.Listener; if (listener != null) { this.ListenerUri = listener.Uri?.ToString(); this.ListenerState = listener.State; TransportChannelListener transportListener = listener as TransportChannelListener; if (transportListener != null) { this.MessageEncoder = transportListener?.MessageEncoderFactory?.Encoder.GetType().FullName; } } ChannelDispatcher dispatcher = channelDispatcher as ChannelDispatcher; if (dispatcher != null) { this.State = dispatcher.State; this.BindingName = dispatcher.BindingName; this.ServiceThrottle = new ServiceThrottleModel(dispatcher.ServiceThrottle); this.CommunicationTimeouts = new CommunicationTimeoutsModel(dispatcher.DefaultCommunicationTimeouts); if (dispatcher.Endpoints != null && dispatcher.Endpoints.Count > 0) { EndpointDispatcher endpointDispatcher = dispatcher.Endpoints[0]; if (endpointDispatcher != null) { this.ContractName = endpointDispatcher.ContractName; this.IsSystemEndpoint = endpointDispatcher.IsSystemEndpoint; this.MessageInspectors = GetMessageInspectors(endpointDispatcher); } } } }
protected override void OnClose(TimeSpan timeout) { try { TimeoutHelper helper = new TimeoutHelper(timeout); if (ManagementExtension.IsEnabled && (this.Description != null)) { ManagementExtension.OnServiceClosing(this); } for (int i = 0; i < this.ChannelDispatchers.Count; i++) { ChannelDispatcherBase base2 = this.ChannelDispatchers[i]; if (base2.Listener != null) { base2.Listener.Close(helper.RemainingTime()); } } for (int j = 0; j < this.ChannelDispatchers.Count; j++) { this.ChannelDispatchers[j].CloseInput(helper.RemainingTime()); } this.instances.CloseInput(helper.RemainingTime()); this.instances.Close(helper.RemainingTime()); for (int k = 0; k < this.ChannelDispatchers.Count; k++) { this.ChannelDispatchers[k].Close(helper.RemainingTime()); } this.TraceBaseAddresses(); ThreadTrace.StopTracing(); } catch (TimeoutException exception) { if (DiagnosticUtility.ShouldTraceWarning) { TraceUtility.TraceEvent(TraceEventType.Warning, 0x8002e, System.ServiceModel.SR.GetString("TraceCodeServiceHostTimeoutOnClose"), this, exception); } base.Abort(); } }