+2004-03-04 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * RealProxy.cs: Added new internal method for getting the proxy type. It
+ gets the proxy type from the MonoRemoteClass (it can change if the
+ vtable is upgraded).
+ Modified GetTransparentProxy(). Now it takes the name of the type.
+ The name is taken from the IRemotingTypeInfo object.
+ * RemotingProxy.cs: The class must implement IRemotingTypeInfo.
+
2004-01-19 Lluis Sanchez Gual <lluis@ximian.com>
* RealProxy.cs: Added setter for ObjectIdentity.
this.class_to_proxy = classToProxy;
// TODO: Fix stub
- _objTP = InternalGetTransparentProxy();
}
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ extern static Type InternalGetProxyType (object transparentProxy);
+
public Type GetProxiedType()
{
- if (class_to_proxy.IsInterface) return typeof (MarshalByRefObject);
- else return class_to_proxy;
+ if (_objTP == null) {
+ if (class_to_proxy.IsInterface) return typeof(MarshalByRefObject);
+ else return class_to_proxy;
+ }
+ return InternalGetProxyType (_objTP);
}
public virtual ObjRef CreateObjRef (Type requestedType)
if (mMsg.CallType == CallType.BeginInvoke)
mMsg.AsyncResult.CallMessage = mMsg; // TODO: do this in the runtime
- IMethodReturnMessage res_msg = (IMethodReturnMessage)rp.Invoke (msg);
-
+ IMethodReturnMessage res_msg = null;
+ res_msg = (IMethodReturnMessage)rp.Invoke (msg);
+
if (res_msg.LogicalCallContext != null && res_msg.LogicalCallContext.HasInfo)
CallContext.UpdateCurrentCallContext (res_msg.LogicalCallContext);
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal extern virtual object InternalGetTransparentProxy ();
+ internal extern virtual object InternalGetTransparentProxy (string className);
public virtual object GetTransparentProxy ()
{
+ if (_objTP == null)
+ {
+ string name;
+ IRemotingTypeInfo rti = this as IRemotingTypeInfo;
+
+ if (rti != null) {
+ name = rti.TypeName;
+ if (name == typeof(MarshalByRefObject).AssemblyQualifiedName)
+ name = class_to_proxy.AssemblyQualifiedName;
+ }
+ else
+ name = class_to_proxy.AssemblyQualifiedName;
+
+ _objTP = InternalGetTransparentProxy (name);
+ }
return _objTP;
}
namespace System.Runtime.Remoting.Proxies
{
- internal class RemotingProxy : RealProxy
+ internal class RemotingProxy : RealProxy, IRemotingTypeInfo
{
static MethodInfo _cache_GetTypeMethod = typeof(System.Object).GetMethod("GetType");
static MethodInfo _cache_GetHashCodeMethod = typeof(System.Object).GetMethod("GetHashCode");
_ctorCall.CopyFrom (request);
return ActivationServices.Activate (this, _ctorCall);
}
+
+ public string TypeName
+ {
+ get
+ {
+ if (_objectIdentity is ClientIdentity) {
+ ObjRef oref = _objectIdentity.CreateObjRef (null);
+ if (oref.TypeInfo != null) return oref.TypeInfo.TypeName;
+ }
+ return GetProxiedType().AssemblyQualifiedName;
+ }
+
+ set
+ {
+ throw new NotSupportedException ();
+ }
+ }
+
+ public bool CanCastTo (Type fromType, object o)
+ {
+ if (_objectIdentity is ClientIdentity) {
+ ObjRef oref = _objectIdentity.CreateObjRef (null);
+ if (oref.TypeInfo != null) return oref.TypeInfo.CanCastTo (fromType, o);
+ }
+ return fromType.IsAssignableFrom (GetProxiedType());
+ }
~RemotingProxy()
{