Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs
diff options
context:
space:
mode:
authorAtsushi Eno <atsushieno@gmail.com>2009-08-07 10:20:19 +0400
committerAtsushi Eno <atsushieno@gmail.com>2009-08-07 10:20:19 +0400
commit1ac99f5eaa4da11ffeeabff80b833f2568f20a9c (patch)
tree2c6e14ad4070a9af94cd7cd71e4e7a16a09a45ae /mcs
parenta8b7f121940fc883ea71fdaba51777cad2389cc5 (diff)
2009-08-07 Atsushi Enomoto <atsushi@ximian.com>
* ServiceEndpoint.cs, ContractDescription.cs : moved client runtime creator from former to latter. * ClientProxyGenerator.cs : split client-specific code generation from those common to service callback generation. * ServiceProxyGenerator.cs : new file, uses common basis above. svn path=/trunk/mcs/; revision=139544
Diffstat (limited to 'mcs')
-rw-r--r--mcs/class/System.ServiceModel/System.ServiceModel.Description/ChangeLog5
-rw-r--r--mcs/class/System.ServiceModel/System.ServiceModel.Description/ContractDescription.cs42
-rw-r--r--mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceEndpoint.cs38
-rwxr-xr-xmcs/class/System.ServiceModel/System.ServiceModel/ChangeLog6
-rw-r--r--mcs/class/System.ServiceModel/System.ServiceModel/ClientProxyGenerator.cs9
-rw-r--r--mcs/class/System.ServiceModel/System.ServiceModel/ServiceProxyGenerator.cs75
6 files changed, 137 insertions, 38 deletions
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/ChangeLog b/mcs/class/System.ServiceModel/System.ServiceModel.Description/ChangeLog
index 5731109d17b..b5aec5220b0 100644
--- a/mcs/class/System.ServiceModel/System.ServiceModel.Description/ChangeLog
+++ b/mcs/class/System.ServiceModel/System.ServiceModel.Description/ChangeLog
@@ -1,3 +1,8 @@
+2009-08-07 Atsushi Enomoto <atsushi@ximian.com>
+
+ * ServiceEndpoint.cs, ContractDescription.cs : moved client runtime
+ creator from former to latter.
+
2009-08-06 Atsushi Enomoto <atsushi@ximian.com>
* ServiceEndpoint.cs : follow ClientRuntime change.
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/ContractDescription.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/ContractDescription.cs
index c5b24acd164..fe016da2135 100644
--- a/mcs/class/System.ServiceModel/System.ServiceModel.Description/ContractDescription.cs
+++ b/mcs/class/System.ServiceModel/System.ServiceModel.Description/ContractDescription.cs
@@ -34,6 +34,7 @@ using System.Reflection;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Channels;
+using System.ServiceModel.Dispatcher;
namespace System.ServiceModel.Description
{
@@ -143,5 +144,46 @@ namespace System.ServiceModel.Description
{
throw new NotImplementedException ();
}
+
+ internal ClientRuntime CreateClientRuntime ()
+ {
+ ClientRuntime proxy = new ClientRuntime (Name, Namespace) { ContractClientType = ContractType, CallbackClientType = CallbackContractType };
+ //proxy.ContractClientType = typeof (TChannel);
+
+ foreach (OperationDescription od in Operations) {
+ if (!proxy.Operations.Contains (od.Name))
+ PopulateClientOperation (proxy, od);
+ foreach (IOperationBehavior ob in od.Behaviors)
+ ob.ApplyClientBehavior (od, proxy.Operations [od.Name]);
+ }
+
+ return proxy;
+ }
+
+ void PopulateClientOperation (ClientRuntime proxy, OperationDescription od)
+ {
+ string reqA = null, resA = null;
+ foreach (MessageDescription m in od.Messages) {
+ if (m.Direction == MessageDirection.Input)
+ reqA = m.Action;
+ else
+ resA = m.Action;
+ }
+ ClientOperation o =
+ od.IsOneWay ?
+ new ClientOperation (proxy, od.Name, reqA) :
+ new ClientOperation (proxy, od.Name, reqA, resA);
+ foreach (MessageDescription md in od.Messages) {
+ if (md.Direction == MessageDirection.Input &&
+ md.Body.Parts.Count == 1 &&
+ md.Body.Parts [0].Type == typeof (Message))
+ o.SerializeRequest = false;
+ if (md.Direction == MessageDirection.Output &&
+ md.Body.ReturnValue != null &&
+ md.Body.ReturnValue.Type == typeof (Message))
+ o.DeserializeReply = false;
+ }
+ proxy.Operations.Add (o);
+ }
}
}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceEndpoint.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceEndpoint.cs
index 12962709216..0cf1558674c 100644
--- a/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceEndpoint.cs
+++ b/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceEndpoint.cs
@@ -115,51 +115,15 @@ namespace System.ServiceModel.Description
{
ServiceEndpoint se = this;
- ClientRuntime proxy = new ClientRuntime (se.Contract);
- //proxy.ContractClientType = typeof (TChannel);
-
- foreach (OperationDescription od in se.Contract.Operations)
- if (!proxy.Operations.Contains (od.Name))
- PopulateClientOperation (proxy, od);
+ var proxy = se.Contract.CreateClientRuntime ();
#if !NET_2_1
foreach (IEndpointBehavior b in se.Behaviors)
b.ApplyClientBehavior (se, proxy);
-
foreach (IContractBehavior b in se.Contract.Behaviors)
b.ApplyClientBehavior (se.Contract, se, proxy);
- foreach (OperationDescription od in se.Contract.Operations)
- foreach (IOperationBehavior ob in od.Behaviors)
- ob.ApplyClientBehavior (od, proxy.Operations [od.Name]);
#endif
-
return proxy;
}
-
- void PopulateClientOperation (ClientRuntime proxy, OperationDescription od)
- {
- string reqA = null, resA = null;
- foreach (MessageDescription m in od.Messages) {
- if (m.Direction == MessageDirection.Input)
- reqA = m.Action;
- else
- resA = m.Action;
- }
- ClientOperation o =
- od.IsOneWay ?
- new ClientOperation (proxy, od.Name, reqA) :
- new ClientOperation (proxy, od.Name, reqA, resA);
- foreach (MessageDescription md in od.Messages) {
- if (md.Direction == MessageDirection.Input &&
- md.Body.Parts.Count == 1 &&
- md.Body.Parts [0].Type == typeof (Message))
- o.SerializeRequest = false;
- if (md.Direction == MessageDirection.Output &&
- md.Body.ReturnValue != null &&
- md.Body.ReturnValue.Type == typeof (Message))
- o.DeserializeReply = false;
- }
- proxy.Operations.Add (o);
- }
}
}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/ChangeLog b/mcs/class/System.ServiceModel/System.ServiceModel/ChangeLog
index 10493c46781..7c38915541c 100755
--- a/mcs/class/System.ServiceModel/System.ServiceModel/ChangeLog
+++ b/mcs/class/System.ServiceModel/System.ServiceModel/ChangeLog
@@ -1,5 +1,11 @@
2009-08-07 Atsushi Enomoto <atsushi@ximian.com>
+ * ClientProxyGenerator.cs : split client-specific code generation
+ from those common to service callback generation.
+ * ServiceProxyGenerator.cs : new file, uses common basis above.
+
+2009-08-07 Atsushi Enomoto <atsushi@ximian.com>
+
* ServiceRuntimeChannel.cs : created derived duplex type.
2009-08-07 Atsushi Enomoto <atsushi@ximian.com>
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/ClientProxyGenerator.cs b/mcs/class/System.ServiceModel/System.ServiceModel/ClientProxyGenerator.cs
index 58c5c2b60d8..d5afac9f95f 100644
--- a/mcs/class/System.ServiceModel/System.ServiceModel/ClientProxyGenerator.cs
+++ b/mcs/class/System.ServiceModel/System.ServiceModel/ClientProxyGenerator.cs
@@ -36,7 +36,7 @@ using Mono.CodeGeneration;
namespace System.ServiceModel
{
- internal class ClientProxyGenerator
+ internal class ClientProxyGenerator : ProxyGeneratorBase
{
public static Type CreateProxyType (Type contractInterface, ContractDescription cd, bool duplex)
{
@@ -70,7 +70,14 @@ namespace System.ServiceModel
new CodeArgumentReference (typeof (ChannelFactory), 2, "arg1"),
new CodeArgumentReference (typeof (EndpointAddress), 3, "arg2"),
new CodeArgumentReference (typeof (Uri), 4, "arg3"));
+ return CreateProxyTypeOperations (crtype, c, cd);
+ }
+ }
+ internal class ProxyGeneratorBase
+ {
+ protected static Type CreateProxyTypeOperations (Type crtype, CodeClass c, ContractDescription cd)
+ {
// member implementation
BindingFlags bf = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
foreach (OperationDescription od in cd.Operations) {
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/ServiceProxyGenerator.cs b/mcs/class/System.ServiceModel/System.ServiceModel/ServiceProxyGenerator.cs
new file mode 100644
index 00000000000..1efd151e42b
--- /dev/null
+++ b/mcs/class/System.ServiceModel/System.ServiceModel/ServiceProxyGenerator.cs
@@ -0,0 +1,75 @@
+//
+// ServiceProxyGenerator.cs
+//
+// Author:
+// Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc. http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using Mono.CodeGeneration;
+
+namespace System.ServiceModel
+{
+ internal class ServiceProxyGenerator : ProxyGeneratorBase
+ {
+ public static Type CreateCallbackProxyType (Type type)
+ {
+ var cd = ContractDescriptionGenerator.GetCallbackContract (type);
+ string modname = "dummy";
+ Type crtype = typeof (DuplexServiceRuntimeChannel);
+
+ // public class __clientproxy_MyContract : ClientRuntimeChannel, [ContractType]
+ CodeClass c = new CodeModule (modname).CreateClass (
+ "__callbackproxy_" + cd.Name,
+ crtype,
+ new Type [] {type});
+
+ //
+ // public __callbackproxy_MyContract (
+ // IChannel channel, DispatchRuntime runtime)
+ // : base (channel, runtime)
+ // {
+ // }
+ //
+ Type [] ctorargs = new Type [] {typeof (IChannel), typeof (DispatchRuntime)};
+ CodeMethod ctor = c.CreateConstructor (
+ MethodAttributes.Public, ctorargs);
+ CodeBuilder b = ctor.CodeBuilder;
+ MethodBase baseCtor = crtype.GetConstructors (
+ BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) [0];
+ if (baseCtor == null) throw new Exception ("INTERNAL ERROR: DuplexServiceRuntimeChannel.ctor() was not found.");
+ b.Call (
+ ctor.GetThis (),
+ baseCtor,
+ new CodeArgumentReference (typeof (IChannel), 1, "channel"),
+ new CodeArgumentReference (typeof (DispatchRuntime), 2, "runtime"));
+
+ return CreateProxyTypeOperations (crtype, c, cd);
+ }
+ }
+}