Ver código fonte

created an new assembly System.Runtime.Remoting

svn path=/trunk/mcs/; revision=6798
Dietmar Maurer 23 anos atrás
pai
commit
0c24279edc

+ 0 - 0
mcs/class/corlib/System.Runtime.Remoting.Channels.Tcp/ChangeLog → mcs/class/System.Runtime.Remoting/ChangeLog


+ 25 - 0
mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.build

@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+
+<!-- NAnt build file for System.Runtime.Remoting.dll -->
+
+<project name="System" default="build">
+	<property name="debug" value="false"/>
+
+	<target name="build">
+		<csc target="library" output="../lib/System.Runtime.Remoting.dll" debug="${debug}">
+			<arg value="/nowarn:1595"/>
+			<arg value="/unsafe"/>
+			<sources>
+				<includes name="**/*.cs"/> 
+				<excludes name="Test/**"/> 
+			</sources>
+			<references>
+				<includes name="../lib/corlib.dll"/>
+				<includes name="../lib/System.dll"/>
+			</references>
+		</csc>
+	</target>
+	<target name="clean">
+		<delete file="../lib/System.Runtime.Remoting.dll" failonerror="false"/>
+	</target>
+</project>

+ 37 - 0
mcs/class/System.Runtime.Remoting/System.Runtime.Remoting/TODOAttribute.cs

@@ -0,0 +1,37 @@
+//
+// TODOAttribute.cs
+//
+// Author:
+//   Ravi Pratap ([email protected])
+//
+// (C) Ximian, Inc.  http://www.ximian.com
+//
+
+namespace System {
+
+	/// <summary>
+	///   The TODO attribute is used to flag all incomplete bits in our class libraries
+	/// </summary>
+	///
+	/// <remarks>
+	///   Use this to decorate any element which you think is not complete
+	/// </remarks>
+	[AttributeUsage (AttributeTargets.All, AllowMultiple=true)]
+	public class MonoTODOAttribute : Attribute {
+
+		private string comment;
+		
+		public MonoTODOAttribute ()
+		{}
+
+		public MonoTODOAttribute (string comment)
+		{
+			this.comment = comment;
+		}
+
+		public string Comment
+		{
+			get { return comment; }
+		}
+	}
+}

+ 0 - 93
mcs/class/corlib/System.Runtime.Remoting.Channels.Tcp/TcpChannel.cs

@@ -1,93 +0,0 @@
-//
-// System.Runtime.Remoting.Channels.Tcp.TcpChannel.cs
-//
-// Author: Rodrigo Moya ([email protected])
-//
-// 2002 (C) Copyright, Ximian, Inc.
-//
-
-using System.Collections;
-using System.Runtime.Remoting.Messaging;
-
-namespace System.Runtime.Remoting.Channels.Tcp
-{
-	public class TcpChannel : IChannelReceiver, IChannel,
-		IChannelSender
-	{
-		private int tcp_port;
-		
-		public TcpChannel ()
-	        {
-			tcp_port = 0;
-		}
-
-		public TcpChannel (int port)
-		{
-			tcp_port = port;
-		}
-
-		[MonoTODO]
-		public TcpChannel (IDictionary properties,
-				   IClientChannelSinkProvider clientSinkProvider,
-				   IServerChannelSinkProvider serverSinkProvider)
-		{
-			throw new NotImplementedException ();
-		}
-
-		public object ChannelData
-		{
-			[MonoTODO]
-			get {
-				throw new NotImplementedException ();
-			}
-		}
-
-		public string ChannelName
-		{
-			[MonoTODO]
-			get {
-				throw new NotImplementedException ();
-			}
-		}
-
-		public int ChannelPriority
-		{
-			[MonoTODO]
-			get {
-				throw new NotImplementedException ();
-			}
-		}
-
-		[MonoTODO]
-		public IMessageSink CreateMessageSink (string url,
-						       object remoteChannelData,
-						       out string objectURI)
-	        {
-			throw new NotImplementedException ();
-		}
-
-		[MonoTODO]
-		public string[] GetUrlsForUri (string objectURI)
-		{
-			throw new NotImplementedException ();
-		}
-
-		[MonoTODO]
-		public string Parse (string url, out string objectURI)
-		{
-			throw new NotImplementedException ();
-		}
-
-		[MonoTODO]
-		public void StartListening (object data)
-		{
-			throw new NotImplementedException ();
-		}
-
-		[MonoTODO]
-		public void StopListening (object data)
-		{
-			throw new NotImplementedException ();
-		}
-	}
-}

+ 68 - 0
mcs/class/corlib/System.Runtime.Remoting.Channels.Tcp/TcpClientChannel.cs

@@ -0,0 +1,68 @@
+//
+// System.Runtime.Remoting.Channels.Tcp.TcpClientChannel.cs
+//
+// Author: Dietmar Maurer ([email protected])
+//
+// 2002 (C) Copyright, Ximian, Inc.
+//
+
+using System.Collections;
+using System.Runtime.Remoting.Messaging;
+using System.Runtime.Remoting.Channels;
+
+namespace System.Runtime.Remoting.Channels.Tcp
+{
+	public class TcpClientChannel : IChannelSender, IChannel
+	{
+		int priority = 1;					
+		string name = "tcp";
+		IClientChannelSinkProvider sink_provider;
+		
+		public TcpClientChannel ()
+	        {
+			sink_provider = null;
+		}
+
+		public TcpClientChannel (IDictionary properties, IClientChannelSinkProvider sinkProvider)
+		{
+			priority = 1;
+			sink_provider = sinkProvider;
+		}
+
+		public TcpClientChannel (string name, IClientChannelSinkProvider sinkProvider)
+		{
+			priority = 1;		
+			this.name = name;
+			sink_provider = sinkProvider;
+		}
+		
+		public string ChannelName
+		{
+			get {
+				return name;
+			}
+		}
+
+		public int ChannelPriority
+		{
+			get {
+				return priority;
+			}
+		}
+
+		[MonoTODO]
+		public IMessageSink CreateMessageSink (string url,
+						       object remoteChannelData,
+						       out string objectURI)
+	        {
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public string Parse (string url, out string objectURI)
+		{
+			throw new NotImplementedException ();
+		}
+
+	}
+}

+ 35 - 0
mcs/class/corlib/System.Runtime.Remoting.Proxies/RemotingProxy.cs

@@ -0,0 +1,35 @@
+//
+// System.Runtime.Remoting.Proxies.RemotingProxy.cs
+//
+// Authors:
+//   Dietmar Maurer ([email protected])
+//
+// (C) 2001 Ximian, Inc.  http://www.ximian.com
+//
+
+using System;
+using System.Runtime.Remoting.Messaging;
+using System.Runtime.Remoting.Channels;
+using System.Runtime.CompilerServices;
+
+
+namespace System.Runtime.Remoting.Proxies
+{
+
+	public class RemotingProxy : RealProxy {
+
+		IMessageSink sink;
+		
+		
+		public RemotingProxy (Type type, IMessageSink sink) : base (type)
+		{
+			this.sink = sink;
+		}
+
+		public override IMessage Invoke (IMessage request)
+		{
+			return sink.SyncProcessMessage (request);
+		}
+
+	}
+}

+ 4 - 0
mcs/class/corlib/System.Runtime.Remoting/ChangeLog

@@ -1,3 +1,7 @@
+2002-08-20  Dietmar Maurer  <[email protected]>
+
+	* RemotingServices.cs: Connect impl. 
+
 2002-08-02  Duncan Mak  <[email protected]>
 
 	* ActivatedClientTypeEntry.cs:

+ 30 - 2
mcs/class/corlib/System.Runtime.Remoting/RemotingServices.cs

@@ -10,6 +10,8 @@
 using System;
 using System.Reflection;
 using System.Runtime.Remoting.Messaging;
+using System.Runtime.Remoting.Proxies;
+using System.Runtime.Remoting.Channels;
 using System.Runtime.CompilerServices;
 
 namespace System.Runtime.Remoting
@@ -44,7 +46,33 @@ namespace System.Runtime.Remoting
 
 			return result;
 		}
-								   
-		
+
+		public static object Connect (Type classToProxy, string url)
+		{
+			IMessageSink sink = null;
+			string uri;
+			
+			IChannel [] channels = ChannelServices.RegisteredChannels;
+
+			foreach (IChannel c in channels) {
+				IChannelSender sender = c as IChannelSender;
+				
+				if (sender != null) {
+					sink = sender.CreateMessageSink (url, null, out uri);
+
+					if (sink != null)
+						break;
+				}
+			}
+
+			if (sink == null) {
+				string msg = String.Format ("Cannot create channel sink to connect to URL {0}.", url); 
+				throw new RemotingException (msg);
+			}
+
+			RemotingProxy real_proxy = new RemotingProxy (classToProxy, sink);
+
+			return real_proxy.GetTransparentProxy ();
+		}
 	}
 }

+ 1 - 0
mcs/class/library.build

@@ -18,6 +18,7 @@
 		<nant basedir="System.Web.Services" target="build"/>
 		<nant basedir="Microsoft.VisualBasic" target="build"/>
 		<nant basedir="System.Configuration.Install" target="build"/>
+		<nant basedir="System.Runtime.Remoting" target="build"/>
 	</target>
 
 	<target name="test">