flush
[mcs.git] / class / System.ServiceModel.Routing / System.ServiceModel.Routing / RoutingBehavior.cs
blob0af8568b2ab4611d62fbfcf42563c24ade49dec2
1 using System;
2 using System.Collections.Generic;
3 using System.Collections.ObjectModel;
4 using System.ServiceModel;
5 using System.ServiceModel.Channels;
6 using System.ServiceModel.Description;
7 using System.ServiceModel.Dispatcher;
9 namespace System.ServiceModel.Routing
11 public sealed class RoutingBehavior : IServiceBehavior
13 // seealso http://msdn.microsoft.com/en-us/library/ee517422%28VS.100%29.aspx
15 [MonoTODO]
16 public static Type GetContractForDescription (ContractDescription description)
18 throw new NotImplementedException ();
21 // instance members
23 public RoutingBehavior (RoutingConfiguration routingConfiguration)
25 if (routingConfiguration == null)
26 throw new ArgumentNullException ("routingConfiguration");
27 config = routingConfiguration;
30 RoutingConfiguration config;
32 void IServiceBehavior.AddBindingParameters (ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters)
34 // nothing to do here.
37 void IServiceBehavior.ApplyDispatchBehavior (ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
39 // FIXME: not sure if this is correct.
40 if (config.SoapProcessingEnabled)
41 foreach (var ses in config.FilterTable.Values)
42 foreach (var se in ses)
43 se.Behaviors.Add (new SoapProcessingBehavior ());
45 var ext = new RoutingExtension ();
46 ((IExtension<ServiceHostBase>) ext).Attach (serviceHostBase);
47 ext.ApplyConfiguration (config);
50 void IServiceBehavior.Validate (ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
52 if (!serviceDescription.ServiceType.IsAssignableFrom (typeof (RoutingService)))
53 throw new InvalidOperationException ("RoutingBehavior can be applied only to RoutingService");