2003-02-03 Patrik Torstensson
[mono.git] / mcs / class / corlib / System.Runtime.Remoting.Proxies / RemotingProxy.cs
1 //
2 // System.Runtime.Remoting.Proxies.RemotingProxy.cs
3 //
4 // Authors:
5 //   Dietmar Maurer (dietmar@ximian.com)
6 //   Lluis Sanchez Gual (lsg@ctv.es)
7 //
8 // (C) 2001 Ximian, Inc.  http://www.ximian.com
9 //
10
11 using System;
12 using System.Reflection;
13 using System.Runtime.Remoting.Messaging;
14 using System.Runtime.Remoting.Channels;
15 using System.Runtime.CompilerServices;
16
17
18 namespace System.Runtime.Remoting.Proxies
19 {
20
21         public class RemotingProxy : RealProxy 
22         {
23                 static MethodInfo _cache_GetTypeMethod = typeof(System.Object).GetMethod("GetType");\r
24                 static MethodInfo _cache_GetHashCodeMethod = typeof(System.Object).GetMethod("GetHashCode");\r
25 \r
26                 IMessageSink _sink;
27
28                 internal RemotingProxy (Type type, Identity identity) : base (type, identity)
29                 {
30                         _sink = identity.ClientSink;
31                 }
32
33                 public override IMessage Invoke (IMessage request)
34                 {
35                         MonoMethodMessage mMsg = (MonoMethodMessage) request;
36
37                         if (mMsg.MethodBase == _cache_GetHashCodeMethod)
38                                 return new MethodResponse(ObjectIdentity.GetHashCode(), null, null, request as IMethodCallMessage);\r
39
40                         if (mMsg.MethodBase == _cache_GetTypeMethod)
41                                 return new MethodResponse(GetProxiedType(), null, null, request as IMethodCallMessage);\r
42
43                         mMsg.Uri = ObjectIdentity.ObjectUri;
44                         return _sink.SyncProcessMessage (request);
45                 }
46
47         }
48 }