192 lines
5.8 KiB
C#
192 lines
5.8 KiB
C#
using System;
|
|
using System.Reflection;
|
|
using System.Runtime.Remoting.Activation;
|
|
using System.Runtime.Remoting.Messaging;
|
|
using System.Threading;
|
|
|
|
namespace System.Runtime.Remoting.Proxies
|
|
{
|
|
// Token: 0x02000434 RID: 1076
|
|
internal class RemotingProxy : RealProxy, IRemotingTypeInfo
|
|
{
|
|
// Token: 0x0600299C RID: 10652 RVA: 0x00085B6C File Offset: 0x00083D6C
|
|
internal RemotingProxy(Type type, ClientIdentity identity)
|
|
: base(type, identity)
|
|
{
|
|
this._sink = identity.ChannelSink;
|
|
this._hasEnvoySink = false;
|
|
this._targetUri = identity.TargetUri;
|
|
}
|
|
|
|
// Token: 0x0600299D RID: 10653 RVA: 0x00085B98 File Offset: 0x00083D98
|
|
internal RemotingProxy(Type type, string activationUrl, object[] activationAttributes)
|
|
: base(type)
|
|
{
|
|
this._hasEnvoySink = false;
|
|
this._ctorCall = ActivationServices.CreateConstructionCall(type, activationUrl, activationAttributes);
|
|
}
|
|
|
|
// Token: 0x0600299F RID: 10655 RVA: 0x00085BF8 File Offset: 0x00083DF8
|
|
public override IMessage Invoke(IMessage request)
|
|
{
|
|
IMethodCallMessage methodCallMessage = request as IMethodCallMessage;
|
|
if (methodCallMessage != null)
|
|
{
|
|
if (methodCallMessage.MethodBase == RemotingProxy._cache_GetHashCodeMethod)
|
|
{
|
|
return new MethodResponse(base.ObjectIdentity.GetHashCode(), null, null, methodCallMessage);
|
|
}
|
|
if (methodCallMessage.MethodBase == RemotingProxy._cache_GetTypeMethod)
|
|
{
|
|
return new MethodResponse(base.GetProxiedType(), null, null, methodCallMessage);
|
|
}
|
|
}
|
|
IInternalMessage internalMessage = request as IInternalMessage;
|
|
if (internalMessage != null)
|
|
{
|
|
if (internalMessage.Uri == null)
|
|
{
|
|
internalMessage.Uri = this._targetUri;
|
|
}
|
|
internalMessage.TargetIdentity = this._objectIdentity;
|
|
}
|
|
this._objectIdentity.NotifyClientDynamicSinks(true, request, true, false);
|
|
IMessageSink messageSink;
|
|
if (Thread.CurrentContext.HasExitSinks && !this._hasEnvoySink)
|
|
{
|
|
messageSink = Thread.CurrentContext.GetClientContextSinkChain();
|
|
}
|
|
else
|
|
{
|
|
messageSink = this._sink;
|
|
}
|
|
MonoMethodMessage monoMethodMessage = request as MonoMethodMessage;
|
|
IMessage message;
|
|
if (monoMethodMessage == null || monoMethodMessage.CallType == CallType.Sync)
|
|
{
|
|
message = messageSink.SyncProcessMessage(request);
|
|
}
|
|
else
|
|
{
|
|
AsyncResult asyncResult = monoMethodMessage.AsyncResult;
|
|
IMessageCtrl messageCtrl = messageSink.AsyncProcessMessage(request, asyncResult);
|
|
if (asyncResult != null)
|
|
{
|
|
asyncResult.SetMessageCtrl(messageCtrl);
|
|
}
|
|
message = new ReturnMessage(null, new object[0], 0, null, monoMethodMessage);
|
|
}
|
|
this._objectIdentity.NotifyClientDynamicSinks(false, request, true, false);
|
|
return message;
|
|
}
|
|
|
|
// Token: 0x060029A0 RID: 10656 RVA: 0x00085D38 File Offset: 0x00083F38
|
|
internal void AttachIdentity(Identity identity)
|
|
{
|
|
this._objectIdentity = identity;
|
|
if (identity is ClientActivatedIdentity)
|
|
{
|
|
ClientActivatedIdentity clientActivatedIdentity = (ClientActivatedIdentity)identity;
|
|
this._targetContext = clientActivatedIdentity.Context;
|
|
base.AttachServer(clientActivatedIdentity.GetServerObject());
|
|
clientActivatedIdentity.SetClientProxy((MarshalByRefObject)this.GetTransparentProxy());
|
|
}
|
|
if (identity is ClientIdentity)
|
|
{
|
|
((ClientIdentity)identity).ClientProxy = (MarshalByRefObject)this.GetTransparentProxy();
|
|
this._targetUri = ((ClientIdentity)identity).TargetUri;
|
|
}
|
|
else
|
|
{
|
|
this._targetUri = identity.ObjectUri;
|
|
}
|
|
if (this._objectIdentity.EnvoySink != null)
|
|
{
|
|
this._sink = this._objectIdentity.EnvoySink;
|
|
this._hasEnvoySink = true;
|
|
}
|
|
else
|
|
{
|
|
this._sink = this._objectIdentity.ChannelSink;
|
|
}
|
|
this._ctorCall = null;
|
|
}
|
|
|
|
// Token: 0x060029A1 RID: 10657 RVA: 0x00085E10 File Offset: 0x00084010
|
|
internal IMessage ActivateRemoteObject(IMethodMessage request)
|
|
{
|
|
if (this._ctorCall == null)
|
|
{
|
|
return new ConstructionResponse(this, null, (IMethodCallMessage)request);
|
|
}
|
|
this._ctorCall.CopyFrom(request);
|
|
return ActivationServices.Activate(this, this._ctorCall);
|
|
}
|
|
|
|
// Token: 0x1700083E RID: 2110
|
|
// (get) Token: 0x060029A2 RID: 10658 RVA: 0x00085E44 File Offset: 0x00084044
|
|
// (set) Token: 0x060029A3 RID: 10659 RVA: 0x00085E90 File Offset: 0x00084090
|
|
public string TypeName
|
|
{
|
|
get
|
|
{
|
|
if (this._objectIdentity is ClientIdentity)
|
|
{
|
|
ObjRef objRef = this._objectIdentity.CreateObjRef(null);
|
|
if (objRef.TypeInfo != null)
|
|
{
|
|
return objRef.TypeInfo.TypeName;
|
|
}
|
|
}
|
|
return base.GetProxiedType().AssemblyQualifiedName;
|
|
}
|
|
set
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
}
|
|
|
|
// Token: 0x060029A4 RID: 10660 RVA: 0x00085E98 File Offset: 0x00084098
|
|
public bool CanCastTo(Type fromType, object o)
|
|
{
|
|
if (this._objectIdentity is ClientIdentity)
|
|
{
|
|
ObjRef objRef = this._objectIdentity.CreateObjRef(null);
|
|
if (objRef.IsReferenceToWellKnow && (fromType.IsInterface || base.GetProxiedType() == typeof(MarshalByRefObject)))
|
|
{
|
|
return true;
|
|
}
|
|
if (objRef.TypeInfo != null)
|
|
{
|
|
return objRef.TypeInfo.CanCastTo(fromType, o);
|
|
}
|
|
}
|
|
return fromType.IsAssignableFrom(base.GetProxiedType());
|
|
}
|
|
|
|
// Token: 0x060029A5 RID: 10661 RVA: 0x00085F14 File Offset: 0x00084114
|
|
~RemotingProxy()
|
|
{
|
|
if (this._objectIdentity != null && !(this._objectIdentity is ClientActivatedIdentity))
|
|
{
|
|
RemotingServices.DisposeIdentity(this._objectIdentity);
|
|
}
|
|
}
|
|
|
|
// Token: 0x04000FFD RID: 4093
|
|
private static MethodInfo _cache_GetTypeMethod = typeof(object).GetMethod("GetType");
|
|
|
|
// Token: 0x04000FFE RID: 4094
|
|
private static MethodInfo _cache_GetHashCodeMethod = typeof(object).GetMethod("GetHashCode");
|
|
|
|
// Token: 0x04000FFF RID: 4095
|
|
private IMessageSink _sink;
|
|
|
|
// Token: 0x04001000 RID: 4096
|
|
private bool _hasEnvoySink;
|
|
|
|
// Token: 0x04001001 RID: 4097
|
|
private ConstructionCall _ctorCall;
|
|
}
|
|
}
|