Procházet zdrojové kódy

Add endpoint behavior support in NET_2_1, which involved not a few additions.

Atsushi Eno před 15 roky
rodič
revize
e60ff5ff90

+ 6 - 1
mcs/class/System.ServiceModel/Dummy_2_1.cs

@@ -53,7 +53,6 @@ namespace System.ServiceModel.Description
 	public interface IPolicyImportExtension {}
 	public interface IWsdlExportExtension {}
 	public interface IWsdlImportExtension {}
-	public interface IContractBehavior {}
 
 	// introduced for silverlight sdk compatibility
 	internal class ServiceReflector
@@ -92,6 +91,12 @@ namespace System.ServiceModel.DiagnosticUtility
 }
 namespace System.ServiceModel.Dispatcher
 {
+	public class EndpointDispatcher
+	{
+		internal EndpointDispatcher ()
+		{
+		}
+	}
 }
 namespace System.ServiceModel.Security
 {

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

@@ -117,7 +117,7 @@ namespace System.ServiceModel.Description
 		}
 
 		internal void Validate () {
-#if !NET_2_1
+#if !MOONLIGHT
 			foreach (IContractBehavior b in Contract.Behaviors)
 				b.Validate (Contract, this);
 			foreach (IEndpointBehavior b in Behaviors)

+ 52 - 45
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/DispatchOperation.cs

@@ -53,8 +53,9 @@ namespace System.ServiceModel.Dispatcher
 			release_after_call, release_before_call,
 			tx_auto_complete, tx_required,
 			auto_dispose_params = true;
-		ImpersonationOption impersonation;
 		IDispatchMessageFormatter formatter;
+#if !NET_2_1
+		ImpersonationOption impersonation;
 		IOperationInvoker invoker;
 		SynchronizedCollection<IParameterInspector> inspectors
 			= new SynchronizedCollection<IParameterInspector> ();
@@ -62,6 +63,7 @@ namespace System.ServiceModel.Dispatcher
 			= new SynchronizedCollection<FaultContractInfo> ();
 		SynchronizedCollection<ICallContextInitializer> ctx_initializers
 			= new SynchronizedCollection<ICallContextInitializer> ();
+#endif
 
 		public DispatchOperation (DispatchRuntime parent,
 			string name, string action)
@@ -91,38 +93,16 @@ namespace System.ServiceModel.Dispatcher
 			get { return action; }
 		}
 
+#if !NET_2_1
 		public SynchronizedCollection<ICallContextInitializer> CallContextInitializers {
 			get { return ctx_initializers; }
 		}
 
-		public bool AutoDisposeParameters {
-			get { return auto_dispose_params; }
-			set {
-				ThrowIfOpened ();
-				auto_dispose_params = value;
-			}
-		}
-
-		public bool DeserializeRequest {
-			get { return deserialize_request; }
-			set {
-				ThrowIfOpened ();
-				deserialize_request = value;
-			}
-		}
-
 		public SynchronizedCollection<FaultContractInfo> FaultContractInfos {
 			get { return fault_contract_infos; }
 		}
 
-		public IDispatchMessageFormatter Formatter {
-			get { return formatter; }
-			set {
-				ThrowIfOpened ();
-				formatter = value;
-			}
-		}
-
+		[MonoTODO ("not considered")]
 		public ImpersonationOption Impersonation {
 			get { return impersonation; }
 			set {
@@ -139,10 +119,6 @@ namespace System.ServiceModel.Dispatcher
 			}
 		}
 
-		public bool IsOneWay {
-			get { return is_oneway; }
-		}
-
 		public bool IsTerminating {
 			get { return is_terminating; }
 			set {
@@ -151,18 +127,10 @@ namespace System.ServiceModel.Dispatcher
 			}
 		}
 
-		public string Name {
-			get { return name; }
-		}
-
 		public SynchronizedCollection<IParameterInspector> ParameterInspectors {
 			get { return inspectors; }
 		}
 
-		public DispatchRuntime Parent {
-			get { return parent; }
-		}
-
 		public bool ReleaseInstanceAfterCall {
 			get { return release_after_call; }
 			set {
@@ -183,14 +151,6 @@ namespace System.ServiceModel.Dispatcher
 			get { return reply_action; }
 		}
 
-		public bool SerializeReply {
-			get { return serialize_reply; }
-			set {
-				ThrowIfOpened ();
-				serialize_reply = value;
-			}
-		}
-
 		public bool TransactionAutoComplete {
 			get { return tx_auto_complete; }
 			set {
@@ -206,9 +166,55 @@ namespace System.ServiceModel.Dispatcher
 				tx_required = value;
 			}
 		}
+#endif
+
+		public bool AutoDisposeParameters {
+			get { return auto_dispose_params; }
+			set {
+				ThrowIfOpened ();
+				auto_dispose_params = value;
+			}
+		}
+
+		public bool DeserializeRequest {
+			get { return deserialize_request; }
+			set {
+				ThrowIfOpened ();
+				deserialize_request = value;
+			}
+		}
+
+		public IDispatchMessageFormatter Formatter {
+			get { return formatter; }
+			set {
+				ThrowIfOpened ();
+				formatter = value;
+			}
+		}
+
+		public bool IsOneWay {
+			get { return is_oneway; }
+		}
+
+		public string Name {
+			get { return name; }
+		}
+
+		public DispatchRuntime Parent {
+			get { return parent; }
+		}
+
+		public bool SerializeReply {
+			get { return serialize_reply; }
+			set {
+				ThrowIfOpened ();
+				serialize_reply = value;
+			}
+		}
 
 		void ThrowIfOpened ()
 		{
+#if !NET_2_1
 			// FIXME: get callback client runtime status when ChannelDispatcher is not available.
 			var state = Parent.ChannelDispatcher != null ? Parent.ChannelDispatcher.State : CommunicationState.Created; // Parent.CallbackClientRuntime.ChannelFactory.State;
 			switch (state) {
@@ -217,6 +223,7 @@ namespace System.ServiceModel.Dispatcher
 				return;
 			}
 			throw new InvalidOperationException ("Cannot change this property after the service host is opened");
+#endif
 		}
 	}
 }

+ 14 - 4
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/DispatchRuntime.cs

@@ -29,18 +29,27 @@ using System;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.Reflection;
+#if !NET_2_1
 using System.IdentityModel.Policy;
-using System.ServiceModel.Channels;
+using System.Web.Security;
+#endif
 using System.Text;
 using System.Threading;
 using System.ServiceModel;
+using System.ServiceModel.Channels;
 using System.ServiceModel.Description;
-using System.Web.Security;
 
 namespace System.ServiceModel.Dispatcher
 {
 	public sealed class DispatchRuntime
 	{
+#if NET_2_1
+		internal DispatchRuntime (EndpointDispatcher dispatcher, ClientRuntime callbackClientRuntime)
+		{
+			UnhandledDispatchOperation = new DispatchOperation (
+				this, "*", "*", "*");
+		}
+#else
 		DispatchOperation.DispatchOperationCollection operations =
 			new DispatchOperation.DispatchOperationCollection ();
 
@@ -137,8 +146,9 @@ namespace System.ServiceModel.Dispatcher
 
 		public Type Type { get; set; }
 
-		public DispatchOperation UnhandledDispatchOperation { get; set; }
-
 		public bool ValidateMustUnderstand { get; set; }
+#endif
+
+		public DispatchOperation UnhandledDispatchOperation { get; set; }
 	}
 }

+ 3 - 0
mcs/class/System.ServiceModel/moonlight_raw_System.ServiceModel.dll.sources

@@ -134,6 +134,7 @@ System.ServiceModel.Description/ContractDescription.cs
 System.ServiceModel.Description/ContractDescriptionGenerator.cs
 System.ServiceModel.Description/FaultDescription.cs
 System.ServiceModel.Description/FaultDescriptionCollection.cs
+System.ServiceModel.Description/IContractBehavior.cs
 System.ServiceModel.Description/IEndpointBehavior.cs
 System.ServiceModel.Description/IOperationBehavior.cs
 System.ServiceModel.Description/MessageBodyDescription.cs
@@ -152,6 +153,8 @@ System.ServiceModel.Description/XmlName.cs
 System.ServiceModel.Dispatcher/BaseMessagesFormatter.cs
 System.ServiceModel.Dispatcher/ClientOperation.cs
 System.ServiceModel.Dispatcher/ClientRuntime.cs
+System.ServiceModel.Dispatcher/DispatchRuntime.cs
+System.ServiceModel.Dispatcher/DispatchOperation.cs
 System.ServiceModel.Dispatcher/FaultContractInfo.cs
 System.ServiceModel.Dispatcher/IChannelInitializer.cs
 System.ServiceModel.Dispatcher/IClientMessageFormatter.cs