Browse Source

2009-08-21 Atsushi Enomoto <[email protected]>

	* ServiceHostBase.cs : some refactoring to isolate dispatcher
	  builder code from here.

	* ServiceMetadataExtension.cs:
	  some dependent changes to ServiceHostBase.


svn path=/trunk/mcs/; revision=140403
Atsushi Eno 16 years ago
parent
commit
194aaa5431

+ 5 - 0
mcs/class/System.ServiceModel/System.ServiceModel.Description/ChangeLog

@@ -1,3 +1,8 @@
+2009-08-21  Atsushi Enomoto  <[email protected]>
+
+	* ServiceMetadataExtension.cs:
+	  some dependent changes to ServiceHostBase.
+
 2009-08-11  Atsushi Enomoto  <[email protected]>
 
 	* DataContractSerializerOperationBehavior.cs : add missing members.

+ 1 - 1
mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceMetadataExtension.cs

@@ -120,7 +120,7 @@ namespace System.ServiceModel.Description
 				ListenUri = uri,
 			};
 
-			ChannelDispatcher channelDispatcher = serviceHostBase.BuildChannelDispatcher (se, new BindingParameterCollection ());
+			ChannelDispatcher channelDispatcher = serviceHostBase.BuildChannelDispatcher (se);
 
 			channelDispatcher.Endpoints [0].DispatchRuntime.InstanceContextProvider = new SingletonInstanceContextProvider (new InstanceContext (serviceHostBase, new HttpGetWsdl (sme, uri)));
 

+ 5 - 0
mcs/class/System.ServiceModel/System.ServiceModel/ChangeLog

@@ -1,3 +1,8 @@
+2009-08-21  Atsushi Enomoto  <[email protected]>
+
+	* ServiceHostBase.cs : some refactoring to isolate dispatcher
+	  builder code from here.
+
 2009-08-21  Atsushi Enomoto  <[email protected]>
 
 	* ServiceHostBase.cs : moved some code to channel/endpoint dispatcher

+ 28 - 11
mcs/class/System.ServiceModel/System.ServiceModel/ServiceHostBase.cs

@@ -37,7 +37,7 @@ using System.Reflection;
 
 namespace System.ServiceModel
 {
-	public abstract class ServiceHostBase
+	public abstract partial class ServiceHostBase
 		: CommunicationObject, IExtensibleObject<ServiceHostBase>, IDisposable
 	{
 		ServiceCredentials credentials;
@@ -360,11 +360,7 @@ namespace System.ServiceModel
 			ServiceEndpoint[] endPoints = new ServiceEndpoint[Description.Endpoints.Count];
 			Description.Endpoints.CopyTo (endPoints, 0);
 			foreach (ServiceEndpoint se in endPoints) {
-				//Let all behaviors add their binding parameters
-				BindingParameterCollection commonParams =
-					new BindingParameterCollection ();
-				AddBindingParameters (commonParams, se);
-				ChannelDispatcher channel = BuildChannelDispatcher (se, commonParams);
+				ChannelDispatcher channel = BuildChannelDispatcher (se);
 				ChannelDispatchers.Add (channel);				
 				endPointToDispatcher[se] = channel;				
 			}
@@ -398,21 +394,33 @@ namespace System.ServiceModel
 
 		}
 
-		internal ChannelDispatcher BuildChannelDispatcher (ServiceEndpoint se, BindingParameterCollection commonParams)
+		internal ChannelDispatcher BuildChannelDispatcher (ServiceEndpoint se)
 		{
+			var commonParams = new BindingParameterCollection ();
+			foreach (IServiceBehavior b in Description.Behaviors)
+				b.AddBindingParameters (Description, this, Description.Endpoints, commonParams);
+
+			return new DispatcherBuilder ().BuildChannelDispatcher (Description.ServiceType, se, commonParams);
+		}
+	}
+
+	partial class DispatcherBuilder
+	{
+		internal ChannelDispatcher BuildChannelDispatcher (Type serviceType, ServiceEndpoint se, BindingParameterCollection commonParams)
+		{
+			//Let all behaviors add their binding parameters
+			AddBindingParameters (commonParams, se);
 			//User the binding parameters to build the channel listener and Dispatcher
 			IChannelListener lf = BuildListener (se, commonParams);
 			ChannelDispatcher cd = new ChannelDispatcher (
 				lf, se.Binding.Name);
-			cd.InitializeServiceEndpoint (Description.ServiceType, se);
+			cd.InitializeServiceEndpoint (serviceType, se);
 			return cd;
 		}
 
 		private void AddBindingParameters (BindingParameterCollection commonParams, ServiceEndpoint endPoint) {
 
 			commonParams.Add (ChannelProtectionRequirements.CreateFromContract (endPoint.Contract));
-			foreach (IServiceBehavior b in Description.Behaviors)
-				b.AddBindingParameters (Description, this, Description.Endpoints, commonParams);
 
 			foreach (IContractBehavior b in endPoint.Contract.Behaviors)
 				b.AddBindingParameters (endPoint.Contract, endPoint, commonParams);
@@ -423,7 +431,10 @@ namespace System.ServiceModel
 					b.AddBindingParameters (operation, commonParams);
 			}
 		}
+	}
 
+	public abstract partial class ServiceHostBase
+	{
 		[MonoTODO]
 		protected void LoadConfigurationSection (ServiceElement element)
 		{
@@ -439,8 +450,11 @@ namespace System.ServiceModel
 					((ChannelDispatcher) cd).StartLoop ();
 			}
 		}
+	}
 
-		IChannelListener BuildListener (ServiceEndpoint se,
+	partial class DispatcherBuilder
+	{
+		static IChannelListener BuildListener (ServiceEndpoint se,
 			BindingParameterCollection pl)
 		{
 			Binding b = se.Binding;
@@ -459,7 +473,10 @@ namespace System.ServiceModel
 				return b.BuildChannelListener<IDuplexSessionChannel> (se.ListenUri, "", se.ListenUriMode, pl);
 			throw new InvalidOperationException ("None of the listener channel types is supported");
 		}
+	}
 
+	public abstract partial class ServiceHostBase
+	{
 		[MonoTODO]
 		protected override sealed void OnAbort ()
 		{