using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Runtime.InteropServices;
+using System.Threading;
namespace System.Runtime.Remoting.Proxies
{
[StructLayout (LayoutKind.Sequential)]
internal class TransparentProxy {
public RealProxy _rp;
- IntPtr _class;
+ Mono.RuntimeRemoteClassHandle _class;
bool _custom_type_info;
+
+ unsafe internal RuntimeType GetProxyType () {
+ RuntimeTypeHandle h = _class.ProxyClass.GetTypeHandle ();
+ return (RuntimeType)Type.GetTypeFromHandle (h);
+ }
+
+ bool IsContextBoundObject {
+ get { return GetProxyType ().IsContextful; }
+ }
+
+ Context TargetContext {
+ get { return _rp._targetContext; }
+ }
+
+ bool InCurrentContext () {
+ return IsContextBoundObject && Object.ReferenceEquals (TargetContext, Thread.CurrentContext);
+ }
+
+ internal object LoadRemoteFieldNew (IntPtr classPtr, IntPtr fieldPtr) {
+ Mono.RuntimeClassHandle classHandle = new Mono.RuntimeClassHandle (classPtr);
+ RuntimeFieldHandle fieldHandle = new RuntimeFieldHandle (fieldPtr);
+ RuntimeTypeHandle typeHandle = classHandle.GetTypeHandle ();
+
+ FieldInfo field = FieldInfo.GetFieldFromHandle (fieldHandle);
+
+ if (InCurrentContext ()) {
+ object o = _rp._server;
+ return field.GetValue(o);
+ }
+
+ object[] inArgs = new object[] { Type.GetTypeFromHandle(typeHandle).FullName,
+ field.Name };
+ object[] outArgsMsg = new object[1];
+ MethodInfo minfo = typeof(object).GetMethod("FieldGetter", BindingFlags.NonPublic | BindingFlags.Instance);
+ if (minfo == null)
+ throw new MissingMethodException ("System.Object", "FieldGetter");
+ MonoMethodMessage msg = new MonoMethodMessage (minfo, inArgs, outArgsMsg);
+ object[] outArgs;
+ Exception exc;
+ RealProxy.PrivateInvoke (_rp, msg, out exc, out outArgs);
+ if (exc != null)
+ throw exc;
+ return outArgs[0];
+ }
}
#pragma warning restore 169, 649
#region Sync with object-internals.h
Type class_to_proxy;
internal Context _targetContext;
- MarshalByRefObject _server;
+ internal MarshalByRefObject _server;
int _targetDomainId = -1;
internal string _targetUri;
internal Identity _objectIdentity;
out object [] out_args)
{
MonoMethodMessage mMsg = (MonoMethodMessage) msg;
- mMsg.LogicalCallContext = CallContext.CreateLogicalCallContext (true);
+ mMsg.LogicalCallContext = Thread.CurrentThread.GetMutableExecutionContext().LogicalCallContext;
CallType call_type = mMsg.CallType;
bool is_remproxy = (rp is RemotingProxy);
}
}
- if (res_msg.LogicalCallContext != null && res_msg.LogicalCallContext.HasInfo)
- CallContext.UpdateCurrentLogicalCallContext (res_msg.LogicalCallContext);
+ if (res_msg.LogicalCallContext != null && res_msg.LogicalCallContext.HasInfo) {
+ Thread.CurrentThread.GetMutableExecutionContext().LogicalCallContext.Merge (res_msg.LogicalCallContext);
+ }
exc = res_msg.Exception;