Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@178 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
14 changed files with 112 additions and 17 deletions
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Text; |
||||
using CustomSinks; |
||||
|
||||
namespace DebuggerLibrary |
||||
{ |
||||
public class RemotingObjectBase: MarshalByRefObject |
||||
{ |
||||
} |
||||
} |
||||
@ -0,0 +1,55 @@
@@ -0,0 +1,55 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Text; |
||||
using System.Runtime.Remoting.Proxies; |
||||
using System.Runtime.Remoting.Messaging; |
||||
using System.Runtime.Remoting.Activation; |
||||
using System.Runtime.Remoting; |
||||
using System.Runtime.Remoting.Services; |
||||
|
||||
namespace CustomSinks |
||||
{ |
||||
[AttributeUsage(AttributeTargets.Class)] |
||||
public class MyProxyAttribute: ProxyAttribute |
||||
{ |
||||
public override MarshalByRefObject CreateInstance(Type type) |
||||
{ |
||||
Console.WriteLine("Creating proxy of type " + type.ToString()); |
||||
MarshalByRefObject instance = base.CreateInstance(type); |
||||
MyProxy proxy = new MyProxy(type, instance); |
||||
return (MarshalByRefObject)proxy.GetTransparentProxy(); |
||||
} |
||||
} |
||||
|
||||
public class MyProxy: RealProxy |
||||
{ |
||||
private MarshalByRefObject realObject; |
||||
|
||||
public MyProxy(Type type, MarshalByRefObject realObject):base(type) |
||||
{ |
||||
this.realObject = realObject; |
||||
} |
||||
|
||||
public override IMessage Invoke(IMessage msg) |
||||
{ |
||||
Console.WriteLine("Proxy called: " + msg.Properties["__MethodName"]); |
||||
if (msg is IConstructionCallMessage) { |
||||
IConstructionCallMessage ctorMsg = (IConstructionCallMessage)msg; |
||||
|
||||
try { |
||||
RemotingServices.GetRealProxy(realObject).InitializeServerObject(ctorMsg); |
||||
} catch (Exception e) { |
||||
} |
||||
|
||||
ObjRef objRef = RemotingServices.Marshal(realObject); |
||||
RemotingServices.Unmarshal(objRef); |
||||
|
||||
MarshalByRefObject transpProxy = (MarshalByRefObject)this.GetTransparentProxy(); |
||||
|
||||
return EnterpriseServicesHelper.CreateConstructionReturnMessage(ctorMsg, transpProxy); |
||||
} else { |
||||
return RemotingServices.ExecuteMessage(realObject, (IMethodCallMessage)msg); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue