PageRenderTime 176ms CodeModel.GetById 170ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/Source/Bifrost.WCF/Execution/ContainerServiceBehavior.cs

#
C# | 39 lines | 33 code | 6 blank | 0 comment | 0 complexity | 3892918d41bc7a7cd1e821e9bf701c50 MD5 | raw file
 1using System.Collections.ObjectModel;
 2using System.Linq;
 3using System.ServiceModel;
 4using System.ServiceModel.Channels;
 5using System.ServiceModel.Description;
 6using System.ServiceModel.Dispatcher;
 7using Bifrost.Execution;
 8
 9namespace Bifrost.WCF.Execution
10{
11	public class ContainerServiceBehavior : IServiceBehavior
12	{
13		IContainer _container;
14
15		public ContainerServiceBehavior(IContainer container)
16		{
17			_container = container;
18		}
19
20
21		public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters)
22		{
23		}
24
25		public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
26		{
27			foreach (var endpointDispatcher in
28				serviceHostBase.ChannelDispatchers.OfType<ChannelDispatcher>().SelectMany(
29					channelDispatcher => channelDispatcher.Endpoints))
30			{
31				endpointDispatcher.DispatchRuntime.InstanceProvider = new ContainerInstanceProvider(_container, serviceDescription.ServiceType);
32			}
33		}
34
35		public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
36		{
37		}
38	}
39}