using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Runtime.Remoting.Activation;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Contexts;
using System.Runtime.Remoting.Lifetime;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting.Proxies;
using System.Runtime.Remoting.Services;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters;
using System.Runtime.Serialization.Formatters.Binary;
using System.Threading;
namespace System.Runtime.Remoting
{
/// Provides several methods for using and publishing remoted objects and proxies. This class cannot be inherited.
// Token: 0x0200044B RID: 1099
[ComVisible(true)]
public sealed class RemotingServices
{
// Token: 0x06002A4B RID: 10827 RVA: 0x00088C64 File Offset: 0x00086E64
private RemotingServices()
{
}
// Token: 0x06002A4C RID: 10828 RVA: 0x00088C6C File Offset: 0x00086E6C
static RemotingServices()
{
RemotingSurrogateSelector remotingSurrogateSelector = new RemotingSurrogateSelector();
StreamingContext streamingContext = new StreamingContext(StreamingContextStates.Remoting, null);
RemotingServices._serializationFormatter = new BinaryFormatter(remotingSurrogateSelector, streamingContext);
RemotingServices._deserializationFormatter = new BinaryFormatter(null, streamingContext);
RemotingServices._serializationFormatter.AssemblyFormat = FormatterAssemblyStyle.Full;
RemotingServices._deserializationFormatter.AssemblyFormat = FormatterAssemblyStyle.Full;
RemotingServices.RegisterInternalChannels();
RemotingServices.app_id = Guid.NewGuid().ToString().Replace('-', '_') + "/";
RemotingServices.CreateWellKnownServerIdentity(typeof(RemoteActivator), "RemoteActivationService.rem", WellKnownObjectMode.Singleton);
RemotingServices.FieldSetterMethod = typeof(object).GetMethod("FieldSetter", BindingFlags.Instance | BindingFlags.NonPublic);
RemotingServices.FieldGetterMethod = typeof(object).GetMethod("FieldGetter", BindingFlags.Instance | BindingFlags.NonPublic);
}
// Token: 0x06002A4D RID: 10829
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern object InternalExecute(MethodBase method, object obj, object[] parameters, out object[] out_args);
// Token: 0x06002A4E RID: 10830
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern MethodBase GetVirtualMethod(Type type, MethodBase method);
/// Returns a Boolean value that indicates whether the given object is a transparent proxy or a real object.
/// A Boolean value that indicates whether the object specified in the parameter is a transparent proxy or a real object.
/// The reference to the object to check.
// Token: 0x06002A4F RID: 10831
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern bool IsTransparentProxy(object proxy);
// Token: 0x06002A50 RID: 10832 RVA: 0x00088D44 File Offset: 0x00086F44
internal static IMethodReturnMessage InternalExecuteMessage(MarshalByRefObject target, IMethodCallMessage reqMsg)
{
Type type = target.GetType();
MethodBase methodBase;
if (reqMsg.MethodBase.DeclaringType == type || reqMsg.MethodBase == RemotingServices.FieldSetterMethod || reqMsg.MethodBase == RemotingServices.FieldGetterMethod)
{
methodBase = reqMsg.MethodBase;
}
else
{
methodBase = RemotingServices.GetVirtualMethod(type, reqMsg.MethodBase);
if (methodBase == null)
{
throw new RemotingException(string.Format("Cannot resolve method {0}:{1}", type, reqMsg.MethodName));
}
}
if (reqMsg.MethodBase.IsGenericMethod)
{
Type[] genericArguments = reqMsg.MethodBase.GetGenericArguments();
methodBase = ((MethodInfo)methodBase).MakeGenericMethod(genericArguments);
}
object obj = CallContext.SetCurrentCallContext(reqMsg.LogicalCallContext);
ReturnMessage returnMessage;
try
{
object[] array;
object obj2 = RemotingServices.InternalExecute(methodBase, target, reqMsg.Args, out array);
ParameterInfo[] parameters = methodBase.GetParameters();
object[] array2 = new object[parameters.Length];
int num = 0;
int num2 = 0;
foreach (ParameterInfo parameterInfo in parameters)
{
if (parameterInfo.IsOut && !parameterInfo.ParameterType.IsByRef)
{
array2[num++] = reqMsg.GetArg(parameterInfo.Position);
}
else if (parameterInfo.ParameterType.IsByRef)
{
array2[num++] = array[num2++];
}
else
{
array2[num++] = null;
}
}
returnMessage = new ReturnMessage(obj2, array2, num, CallContext.CreateLogicalCallContext(true), reqMsg);
}
catch (Exception ex)
{
returnMessage = new ReturnMessage(ex, reqMsg);
}
CallContext.RestoreCallContext(obj);
return returnMessage;
}
/// Connects to the specified remote object, and executes the provided on it.
/// The response of the remote method.
/// The remote object whose method you want to call.
/// A method call message to the specified remote object's method.
/// The immediate caller does not have infrastructure permission.
/// The method was called from a context other than the native context of the object.
///
///
///
///
// Token: 0x06002A51 RID: 10833 RVA: 0x00088F00 File Offset: 0x00087100
public static IMethodReturnMessage ExecuteMessage(MarshalByRefObject target, IMethodCallMessage reqMsg)
{
if (RemotingServices.IsTransparentProxy(target))
{
RealProxy realProxy = RemotingServices.GetRealProxy(target);
return (IMethodReturnMessage)realProxy.Invoke(reqMsg);
}
return RemotingServices.InternalExecuteMessage(target, reqMsg);
}
/// Creates a proxy for a well-known object, given the and URL.
/// A proxy to the remote object that points to an endpoint served by the specified well-known object.
/// The of a well-known object on the server end to which you want to connect.
/// The URL of the server class.
/// The immediate caller does not have permission to configure remoting types and channels.
///
///
///
// Token: 0x06002A52 RID: 10834 RVA: 0x00088F34 File Offset: 0x00087134
[ComVisible(true)]
public static object Connect(Type classToProxy, string url)
{
ObjRef objRef = new ObjRef(classToProxy, url, null);
return RemotingServices.GetRemoteObject(objRef, classToProxy);
}
/// Creates a proxy for a well-known object, given the , URL, and channel-specific data.
/// A proxy that points to an endpoint that is served by the requested well-known object.
/// The of the well-known object to which you want to connect.
/// The URL of the well-known object.
/// Channel specific data. Can be null.
/// The immediate caller does not have permission to configure remoting types and channels.
///
///
///
// Token: 0x06002A53 RID: 10835 RVA: 0x00088F54 File Offset: 0x00087154
[ComVisible(true)]
public static object Connect(Type classToProxy, string url, object data)
{
ObjRef objRef = new ObjRef(classToProxy, url, data);
return RemotingServices.GetRemoteObject(objRef, classToProxy);
}
/// Stops an object from receiving any further messages through the registered remoting channels.
/// true if the object was disconnected from the registered remoting channels successfully; otherwise, false.
/// Object to disconnect from its channel.
/// The parameter is null.
/// The parameter is a proxy.
/// The immediate caller does not have permission to configure remoting types and channels.
///
///
///
// Token: 0x06002A54 RID: 10836 RVA: 0x00088F74 File Offset: 0x00087174
public static bool Disconnect(MarshalByRefObject obj)
{
if (obj == null)
{
throw new ArgumentNullException("obj");
}
ServerIdentity serverIdentity;
if (RemotingServices.IsTransparentProxy(obj))
{
RealProxy realProxy = RemotingServices.GetRealProxy(obj);
if (!realProxy.GetProxiedType().IsContextful || !(realProxy.ObjectIdentity is ServerIdentity))
{
throw new ArgumentException("The obj parameter is a proxy.");
}
serverIdentity = realProxy.ObjectIdentity as ServerIdentity;
}
else
{
serverIdentity = obj.ObjectIdentity;
obj.ObjectIdentity = null;
}
if (serverIdentity == null || !serverIdentity.IsConnected)
{
return false;
}
LifetimeServices.StopTrackingLifetime(serverIdentity);
RemotingServices.DisposeIdentity(serverIdentity);
TrackingServices.NotifyDisconnectedObject(obj);
return true;
}
/// Returns the of the object with the specified URI.
/// The of the object with the specified URI.
/// The URI of the object whose is requested.
/// Either the immediate caller does not have infrastructure permission, or at least one of the callers higher in the callstack does not have permission to retrieve the type information of non-public members.
///
///
///
// Token: 0x06002A55 RID: 10837 RVA: 0x0008901C File Offset: 0x0008721C
public static Type GetServerTypeForUri(string URI)
{
ServerIdentity serverIdentity = RemotingServices.GetIdentityForUri(URI) as ServerIdentity;
if (serverIdentity == null)
{
return null;
}
return serverIdentity.ObjectType;
}
/// Retrieves the URI for the specified object.
/// The URI of the specified object if it has one, or null if the object has not yet been marshaled.
/// The for which a URI is requested.
/// The immediate caller does not have infrastructure permission.
///
///
///
// Token: 0x06002A56 RID: 10838 RVA: 0x00089044 File Offset: 0x00087244
public static string GetObjectUri(MarshalByRefObject obj)
{
Identity objectIdentity = RemotingServices.GetObjectIdentity(obj);
if (objectIdentity is ClientIdentity)
{
return ((ClientIdentity)objectIdentity).TargetUri;
}
if (objectIdentity != null)
{
return objectIdentity.ObjectUri;
}
return null;
}
/// Takes a and creates a proxy object out of it.
/// A proxy to the object that the given represents.
/// The that represents the remote object for which the proxy is being created.
/// The instance specified in the parameter is not well-formed.
/// At least one of the callers higher in the callstack does not have permission to configure remoting types and channels.
///
///
///
///
///
// Token: 0x06002A57 RID: 10839 RVA: 0x00089080 File Offset: 0x00087280
public static object Unmarshal(ObjRef objectRef)
{
return RemotingServices.Unmarshal(objectRef, true);
}
/// Takes a and creates a proxy object out of it, refining it to the type on the server.
/// A proxy to the object that the given represents.
/// The that represents the remote object for which the proxy is being created.
/// true to refine the proxy to the type on the server; otherwise, false.
/// The instance specified in the parameter is not well-formed.
/// At least one of the callers higher in the callstack does not have permission to configure remoting types and channels.
///
///
///
///
///
// Token: 0x06002A58 RID: 10840 RVA: 0x0008908C File Offset: 0x0008728C
public static object Unmarshal(ObjRef objectRef, bool fRefine)
{
Type type = ((!fRefine) ? typeof(MarshalByRefObject) : objectRef.ServerType);
if (type == null)
{
type = typeof(MarshalByRefObject);
}
if (objectRef.IsReferenceToWellKnow)
{
object remoteObject = RemotingServices.GetRemoteObject(objectRef, type);
TrackingServices.NotifyUnmarshaledObject(remoteObject, objectRef);
return remoteObject;
}
object obj;
if (type.IsContextful)
{
ProxyAttribute proxyAttribute = (ProxyAttribute)Attribute.GetCustomAttribute(type, typeof(ProxyAttribute), true);
if (proxyAttribute != null)
{
obj = proxyAttribute.CreateProxy(objectRef, type, null, null).GetTransparentProxy();
TrackingServices.NotifyUnmarshaledObject(obj, objectRef);
return obj;
}
}
obj = RemotingServices.GetProxyForRemoteObject(objectRef, type);
TrackingServices.NotifyUnmarshaledObject(obj, objectRef);
return obj;
}
/// Takes a , registers it with the remoting infrastructure, and converts it into an instance of the class.
/// An instance of the class that represents the object specified in the parameter.
/// The object to convert.
/// The parameter is an object proxy.
/// At least one of the callers higher in the callstack does not have permission to configure remoting types and channels.
///
///
///
///
// Token: 0x06002A59 RID: 10841 RVA: 0x00089134 File Offset: 0x00087334
public static ObjRef Marshal(MarshalByRefObject Obj)
{
return RemotingServices.Marshal(Obj, null, null);
}
/// Converts the given into an instance of the class with the specified URI.
/// An instance of the class that represents the object specified in the parameter.
/// The object to convert.
/// The specified URI with which to initialize the new . Can be null.
///
/// is an object proxy, and the parameter is not null.
/// At least one of the callers higher in the callstack does not have permission to configure remoting types and channels.
///
///
///
///
// Token: 0x06002A5A RID: 10842 RVA: 0x00089140 File Offset: 0x00087340
public static ObjRef Marshal(MarshalByRefObject Obj, string URI)
{
return RemotingServices.Marshal(Obj, URI, null);
}
/// Takes a and converts it into an instance of the class with the specified URI, and the provided .
/// An instance of the class that represents the object specified in the parameter.
/// The object to convert into a .
/// The URI the object specified in the parameter is marshaled with. Can be null.
/// The is marshaled as. Can be null.
///
/// is a proxy of a remote object, and the parameter is not null.
/// At least one of the callers higher in the callstack does not have permission to configure remoting types and channels.
///
///
///
///
// Token: 0x06002A5B RID: 10843 RVA: 0x0008914C File Offset: 0x0008734C
public static ObjRef Marshal(MarshalByRefObject Obj, string ObjURI, Type RequestedType)
{
if (RemotingServices.IsTransparentProxy(Obj))
{
RealProxy realProxy = RemotingServices.GetRealProxy(Obj);
Identity objectIdentity = realProxy.ObjectIdentity;
if (objectIdentity != null)
{
if (realProxy.GetProxiedType().IsContextful && !objectIdentity.IsConnected)
{
ClientActivatedIdentity clientActivatedIdentity = (ClientActivatedIdentity)objectIdentity;
if (ObjURI == null)
{
ObjURI = RemotingServices.NewUri();
}
clientActivatedIdentity.ObjectUri = ObjURI;
RemotingServices.RegisterServerIdentity(clientActivatedIdentity);
clientActivatedIdentity.StartTrackingLifetime((ILease)Obj.InitializeLifetimeService());
return clientActivatedIdentity.CreateObjRef(RequestedType);
}
if (ObjURI != null)
{
throw new RemotingException("It is not possible marshal a proxy of a remote object.");
}
ObjRef objRef = realProxy.ObjectIdentity.CreateObjRef(RequestedType);
TrackingServices.NotifyMarshaledObject(Obj, objRef);
return objRef;
}
}
if (RequestedType == null)
{
RequestedType = Obj.GetType();
}
if (ObjURI == null)
{
if (Obj.ObjectIdentity == null)
{
ObjURI = RemotingServices.NewUri();
RemotingServices.CreateClientActivatedServerIdentity(Obj, RequestedType, ObjURI);
}
}
else
{
ClientActivatedIdentity clientActivatedIdentity2 = RemotingServices.GetIdentityForUri("/" + ObjURI) as ClientActivatedIdentity;
if (clientActivatedIdentity2 == null || Obj != clientActivatedIdentity2.GetServerObject())
{
RemotingServices.CreateClientActivatedServerIdentity(Obj, RequestedType, ObjURI);
}
}
ObjRef objRef2;
if (RemotingServices.IsTransparentProxy(Obj))
{
objRef2 = RemotingServices.GetRealProxy(Obj).ObjectIdentity.CreateObjRef(RequestedType);
}
else
{
objRef2 = Obj.CreateObjRef(RequestedType);
}
TrackingServices.NotifyMarshaledObject(Obj, objRef2);
return objRef2;
}
// Token: 0x06002A5C RID: 10844 RVA: 0x00089294 File Offset: 0x00087494
private static string NewUri()
{
int num = Interlocked.Increment(ref RemotingServices.next_id);
return string.Concat(new object[]
{
RemotingServices.app_id,
Environment.TickCount.ToString("x"),
"_",
num,
".rem"
});
}
/// Returns the real proxy backing the specified transparent proxy.
/// The real proxy instance backing the transparent proxy.
/// A transparent proxy.
/// The immediate caller does not have infrastructure permission.
///
///
///
// Token: 0x06002A5D RID: 10845 RVA: 0x000892F0 File Offset: 0x000874F0
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static RealProxy GetRealProxy(object proxy)
{
if (!RemotingServices.IsTransparentProxy(proxy))
{
throw new RemotingException("Cannot get the real proxy from an object that is not a transparent proxy.");
}
return ((TransparentProxy)proxy)._rp;
}
/// Returns the method base from the given .
/// The method base extracted from the parameter.
/// The method message to extract the method base from.
/// Either the immediate caller does not have infrastructure permission, or at least one of the callers higher in the callstack does not have permission to retrieve the type information of non-public members.
///
///
///
// Token: 0x06002A5E RID: 10846 RVA: 0x00089314 File Offset: 0x00087514
public static MethodBase GetMethodBaseFromMethodMessage(IMethodMessage msg)
{
Type type = Type.GetType(msg.TypeName);
if (type == null)
{
throw new RemotingException("Type '" + msg.TypeName + "' not found.");
}
return RemotingServices.GetMethodBaseFromName(type, msg.MethodName, (Type[])msg.MethodSignature);
}
// Token: 0x06002A5F RID: 10847 RVA: 0x00089368 File Offset: 0x00087568
internal static MethodBase GetMethodBaseFromName(Type type, string methodName, Type[] signature)
{
if (type.IsInterface)
{
return RemotingServices.FindInterfaceMethod(type, methodName, signature);
}
MethodBase methodBase;
if (signature == null)
{
methodBase = type.GetMethod(methodName, RemotingServices.methodBindings);
}
else
{
methodBase = type.GetMethod(methodName, RemotingServices.methodBindings, null, signature, null);
}
if (methodBase != null)
{
return methodBase;
}
if (methodName == "FieldSetter")
{
return RemotingServices.FieldSetterMethod;
}
if (methodName == "FieldGetter")
{
return RemotingServices.FieldGetterMethod;
}
if (signature == null)
{
return type.GetConstructor(RemotingServices.methodBindings, null, Type.EmptyTypes, null);
}
return type.GetConstructor(RemotingServices.methodBindings, null, signature, null);
}
// Token: 0x06002A60 RID: 10848 RVA: 0x00089410 File Offset: 0x00087610
private static MethodBase FindInterfaceMethod(Type type, string methodName, Type[] signature)
{
MethodBase methodBase;
if (signature == null)
{
methodBase = type.GetMethod(methodName, RemotingServices.methodBindings);
}
else
{
methodBase = type.GetMethod(methodName, RemotingServices.methodBindings, null, signature, null);
}
if (methodBase != null)
{
return methodBase;
}
foreach (Type type2 in type.GetInterfaces())
{
methodBase = RemotingServices.FindInterfaceMethod(type2, methodName, signature);
if (methodBase != null)
{
return methodBase;
}
}
return null;
}
/// Serializes the specified marshal by reference object into the provided .
/// The object to serialize.
/// The into which the object is serialized.
/// The source and destination of the serialization.
/// The or parameter is null.
/// The immediate caller does not have infrastructure permission.
///
///
///
///
// Token: 0x06002A61 RID: 10849 RVA: 0x00089480 File Offset: 0x00087680
public static void GetObjectData(object obj, SerializationInfo info, StreamingContext context)
{
if (obj == null)
{
throw new ArgumentNullException("obj");
}
ObjRef objRef = RemotingServices.Marshal((MarshalByRefObject)obj);
objRef.GetObjectData(info, context);
}
/// Returns the that represents the remote object from the specified proxy.
/// A that represents the remote object the specified proxy is connected to, or null if the object or proxy have not been marshaled.
/// A proxy connected to the object you want to create a for.
/// The immediate caller does not have infrastructure permission.
///
///
///
// Token: 0x06002A62 RID: 10850 RVA: 0x000894B4 File Offset: 0x000876B4
public static ObjRef GetObjRefForProxy(MarshalByRefObject obj)
{
Identity objectIdentity = RemotingServices.GetObjectIdentity(obj);
if (objectIdentity == null)
{
return null;
}
return objectIdentity.CreateObjRef(null);
}
/// Returns a lifetime service object that controls the lifetime policy of the specified object.
/// The object that controls the lifetime of .
/// The object to obtain lifetime service for.
/// The immediate caller does not have infrastructure permission.
///
///
///
// Token: 0x06002A63 RID: 10851 RVA: 0x000894D8 File Offset: 0x000876D8
public static object GetLifetimeService(MarshalByRefObject obj)
{
if (obj == null)
{
return null;
}
return obj.GetLifetimeService();
}
/// Returns a chain of envoy sinks that should be used when sending messages to the remote object represented by the specified proxy.
/// A chain of envoy sinks associated with the specified proxy.
/// The proxy of the remote object that requested envoy sinks are associated with.
/// The immediate caller does not have infrastructure permission.
///
///
///
// Token: 0x06002A64 RID: 10852 RVA: 0x000894E8 File Offset: 0x000876E8
public static IMessageSink GetEnvoyChainForProxy(MarshalByRefObject obj)
{
if (RemotingServices.IsTransparentProxy(obj))
{
return ((ClientIdentity)RemotingServices.GetRealProxy(obj).ObjectIdentity).EnvoySink;
}
throw new ArgumentException("obj must be a proxy.", "obj");
}
/// Logs the stage in a remoting exchange to an external debugger.
/// An internally defined constant that identifies the stage in a remoting exchange.
///
///
///
// Token: 0x06002A65 RID: 10853 RVA: 0x00089528 File Offset: 0x00087728
[Obsolete("It existed for only internal use in .NET and unimplemented in mono")]
[MonoTODO]
[Conditional("REMOTING_PERF")]
public static void LogRemotingStage(int stage)
{
throw new NotImplementedException();
}
/// Retrieves a session ID for a message.
/// A session ID string that uniquely identifies the current session.
/// The for which a session ID is requested.
/// The immediate caller does not have infrastructure permission.
///
///
///
// Token: 0x06002A66 RID: 10854 RVA: 0x00089530 File Offset: 0x00087730
public static string GetSessionIdForMethodMessage(IMethodMessage msg)
{
return msg.Uri;
}
/// Returns a Boolean value that indicates whether the method in the given message is overloaded.
/// true if the method called in is overloaded; otherwise, false.
/// The message that contains a call to the method in question.
/// The immediate caller does not have infrastructure permission.
///
///
///
// Token: 0x06002A67 RID: 10855 RVA: 0x00089538 File Offset: 0x00087738
public static bool IsMethodOverloaded(IMethodMessage msg)
{
MonoType monoType = (MonoType)msg.MethodBase.DeclaringType;
return monoType.GetMethodsByName(msg.MethodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, false, monoType).Length > 1;
}
/// Returns a Boolean value that indicates whether the object specified by the given transparent proxy is contained in a different application domain than the object that called the current method.
/// true if the object is out of the current application domain; otherwise, false.
/// The object to check.
// Token: 0x06002A68 RID: 10856 RVA: 0x0008956C File Offset: 0x0008776C
public static bool IsObjectOutOfAppDomain(object tp)
{
MarshalByRefObject marshalByRefObject = tp as MarshalByRefObject;
if (marshalByRefObject == null)
{
return false;
}
Identity objectIdentity = RemotingServices.GetObjectIdentity(marshalByRefObject);
return objectIdentity is ClientIdentity;
}
/// Returns a Boolean value that indicates whether the object represented by the given proxy is contained in a different context than the object that called the current method.
/// true if the object is out of the current context; otherwise, false.
/// The object to check.
// Token: 0x06002A69 RID: 10857 RVA: 0x00089598 File Offset: 0x00087798
public static bool IsObjectOutOfContext(object tp)
{
MarshalByRefObject marshalByRefObject = tp as MarshalByRefObject;
if (marshalByRefObject == null)
{
return false;
}
Identity objectIdentity = RemotingServices.GetObjectIdentity(marshalByRefObject);
if (objectIdentity == null)
{
return false;
}
ServerIdentity serverIdentity = objectIdentity as ServerIdentity;
return serverIdentity == null || serverIdentity.Context != Thread.CurrentContext;
}
/// Returns a Boolean value that indicates whether the client that called the method specified in the given message is waiting for the server to finish processing the method before continuing execution.
/// true if the method is one way; otherwise, false.
/// The method in question.
/// The immediate caller does not have infrastructure permission.
///
///
///
// Token: 0x06002A6A RID: 10858 RVA: 0x000895E4 File Offset: 0x000877E4
public static bool IsOneWay(MethodBase method)
{
return method.IsDefined(typeof(OneWayAttribute), false);
}
// Token: 0x06002A6B RID: 10859 RVA: 0x000895F8 File Offset: 0x000877F8
internal static bool IsAsyncMessage(IMessage msg)
{
return msg is MonoMethodMessage && (((MonoMethodMessage)msg).IsAsync || RemotingServices.IsOneWay(((MonoMethodMessage)msg).MethodBase));
}
/// Sets the URI for the subsequent call to the method.
/// The object to set a URI for.
/// The URI to assign to the specified object.
///
/// is not a local object, has already been marshaled, or the current method has already been called on.
/// At least one of the callers higher in the callstack does not have permission to configure remoting types and channels.
///
///
///
// Token: 0x06002A6C RID: 10860 RVA: 0x0008963C File Offset: 0x0008783C
public static void SetObjectUriForMarshal(MarshalByRefObject obj, string uri)
{
if (RemotingServices.IsTransparentProxy(obj))
{
RealProxy realProxy = RemotingServices.GetRealProxy(obj);
Identity objectIdentity = realProxy.ObjectIdentity;
if (objectIdentity != null && !(objectIdentity is ServerIdentity) && !realProxy.GetProxiedType().IsContextful)
{
throw new RemotingException("SetObjectUriForMarshal method should only be called for MarshalByRefObjects that exist in the current AppDomain.");
}
}
RemotingServices.Marshal(obj, uri);
}
// Token: 0x06002A6D RID: 10861 RVA: 0x00089698 File Offset: 0x00087898
internal static object CreateClientProxy(ActivatedClientTypeEntry entry, object[] activationAttributes)
{
if (entry.ContextAttributes != null || activationAttributes != null)
{
ArrayList arrayList = new ArrayList();
if (entry.ContextAttributes != null)
{
arrayList.AddRange(entry.ContextAttributes);
}
if (activationAttributes != null)
{
arrayList.AddRange(activationAttributes);
}
return RemotingServices.CreateClientProxy(entry.ObjectType, entry.ApplicationUrl, arrayList.ToArray());
}
return RemotingServices.CreateClientProxy(entry.ObjectType, entry.ApplicationUrl, null);
}
// Token: 0x06002A6E RID: 10862 RVA: 0x0008970C File Offset: 0x0008790C
internal static object CreateClientProxy(Type objectType, string url, object[] activationAttributes)
{
string text = url;
if (!text.EndsWith("/"))
{
text += "/";
}
text += "RemoteActivationService.rem";
string text2;
RemotingServices.GetClientChannelSinkChain(text, null, out text2);
RemotingProxy remotingProxy = new RemotingProxy(objectType, text, activationAttributes);
return remotingProxy.GetTransparentProxy();
}
// Token: 0x06002A6F RID: 10863 RVA: 0x0008975C File Offset: 0x0008795C
internal static object CreateClientProxy(WellKnownClientTypeEntry entry)
{
return RemotingServices.Connect(entry.ObjectType, entry.ObjectUrl, null);
}
// Token: 0x06002A70 RID: 10864 RVA: 0x00089770 File Offset: 0x00087970
internal static object CreateClientProxyForContextBound(Type type, object[] activationAttributes)
{
if (type.IsContextful)
{
ProxyAttribute proxyAttribute = (ProxyAttribute)Attribute.GetCustomAttribute(type, typeof(ProxyAttribute), true);
if (proxyAttribute != null)
{
return proxyAttribute.CreateInstance(type);
}
}
RemotingProxy remotingProxy = new RemotingProxy(type, ChannelServices.CrossContextUrl, activationAttributes);
return remotingProxy.GetTransparentProxy();
}
// Token: 0x06002A71 RID: 10865 RVA: 0x000897C0 File Offset: 0x000879C0
internal static Identity GetIdentityForUri(string uri)
{
string text = RemotingServices.GetNormalizedUri(uri);
Hashtable hashtable = RemotingServices.uri_hash;
Identity identity2;
lock (hashtable)
{
Identity identity = (Identity)RemotingServices.uri_hash[text];
if (identity == null)
{
text = RemotingServices.RemoveAppNameFromUri(uri);
if (text != null)
{
identity = (Identity)RemotingServices.uri_hash[text];
}
}
identity2 = identity;
}
return identity2;
}
// Token: 0x06002A72 RID: 10866 RVA: 0x00089848 File Offset: 0x00087A48
private static string RemoveAppNameFromUri(string uri)
{
string text = RemotingConfiguration.ApplicationName;
if (text == null)
{
return null;
}
text = "/" + text + "/";
if (uri.StartsWith(text))
{
return uri.Substring(text.Length);
}
return null;
}
// Token: 0x06002A73 RID: 10867 RVA: 0x00089890 File Offset: 0x00087A90
internal static Identity GetObjectIdentity(MarshalByRefObject obj)
{
if (RemotingServices.IsTransparentProxy(obj))
{
return RemotingServices.GetRealProxy(obj).ObjectIdentity;
}
return obj.ObjectIdentity;
}
// Token: 0x06002A74 RID: 10868 RVA: 0x000898B0 File Offset: 0x00087AB0
internal static ClientIdentity GetOrCreateClientIdentity(ObjRef objRef, Type proxyType, out object clientProxy)
{
object obj = ((objRef.ChannelInfo == null) ? null : objRef.ChannelInfo.ChannelData);
string uri;
IMessageSink clientChannelSinkChain = RemotingServices.GetClientChannelSinkChain(objRef.URI, obj, out uri);
if (uri == null)
{
uri = objRef.URI;
}
Hashtable hashtable = RemotingServices.uri_hash;
ClientIdentity clientIdentity2;
lock (hashtable)
{
clientProxy = null;
string normalizedUri = RemotingServices.GetNormalizedUri(objRef.URI);
ClientIdentity clientIdentity = RemotingServices.uri_hash[normalizedUri] as ClientIdentity;
if (clientIdentity != null)
{
clientProxy = clientIdentity.ClientProxy;
if (clientProxy != null)
{
return clientIdentity;
}
RemotingServices.DisposeIdentity(clientIdentity);
}
clientIdentity = new ClientIdentity(uri, objRef);
clientIdentity.ChannelSink = clientChannelSinkChain;
RemotingServices.uri_hash[normalizedUri] = clientIdentity;
if (proxyType != null)
{
RemotingProxy remotingProxy = new RemotingProxy(proxyType, clientIdentity);
CrossAppDomainSink crossAppDomainSink = clientChannelSinkChain as CrossAppDomainSink;
if (crossAppDomainSink != null)
{
remotingProxy.SetTargetDomain(crossAppDomainSink.TargetDomainId);
}
clientProxy = remotingProxy.GetTransparentProxy();
clientIdentity.ClientProxy = (MarshalByRefObject)clientProxy;
}
clientIdentity2 = clientIdentity;
}
return clientIdentity2;
}
// Token: 0x06002A75 RID: 10869 RVA: 0x000899E4 File Offset: 0x00087BE4
private static IMessageSink GetClientChannelSinkChain(string url, object channelData, out string objectUri)
{
IMessageSink messageSink = ChannelServices.CreateClientChannelSinkChain(url, channelData, out objectUri);
if (messageSink != null)
{
return messageSink;
}
if (url != null)
{
string text = string.Format("Cannot create channel sink to connect to URL {0}. An appropriate channel has probably not been registered.", url);
throw new RemotingException(text);
}
string text2 = string.Format("Cannot create channel sink to connect to the remote object. An appropriate channel has probably not been registered.", url);
throw new RemotingException(text2);
}
// Token: 0x06002A76 RID: 10870 RVA: 0x00089A30 File Offset: 0x00087C30
internal static ClientActivatedIdentity CreateContextBoundObjectIdentity(Type objectType)
{
return new ClientActivatedIdentity(null, objectType)
{
ChannelSink = ChannelServices.CrossContextChannel
};
}
// Token: 0x06002A77 RID: 10871 RVA: 0x00089A54 File Offset: 0x00087C54
internal static ClientActivatedIdentity CreateClientActivatedServerIdentity(MarshalByRefObject realObject, Type objectType, string objectUri)
{
ClientActivatedIdentity clientActivatedIdentity = new ClientActivatedIdentity(objectUri, objectType);
clientActivatedIdentity.AttachServerObject(realObject, Context.DefaultContext);
RemotingServices.RegisterServerIdentity(clientActivatedIdentity);
clientActivatedIdentity.StartTrackingLifetime((ILease)realObject.InitializeLifetimeService());
return clientActivatedIdentity;
}
// Token: 0x06002A78 RID: 10872 RVA: 0x00089A90 File Offset: 0x00087C90
internal static ServerIdentity CreateWellKnownServerIdentity(Type objectType, string objectUri, WellKnownObjectMode mode)
{
ServerIdentity serverIdentity;
if (mode == WellKnownObjectMode.SingleCall)
{
serverIdentity = new SingleCallIdentity(objectUri, Context.DefaultContext, objectType);
}
else
{
serverIdentity = new SingletonIdentity(objectUri, Context.DefaultContext, objectType);
}
RemotingServices.RegisterServerIdentity(serverIdentity);
return serverIdentity;
}
// Token: 0x06002A79 RID: 10873 RVA: 0x00089ACC File Offset: 0x00087CCC
private static void RegisterServerIdentity(ServerIdentity identity)
{
Hashtable hashtable = RemotingServices.uri_hash;
lock (hashtable)
{
if (RemotingServices.uri_hash.ContainsKey(identity.ObjectUri))
{
throw new RemotingException("Uri already in use: " + identity.ObjectUri + ".");
}
RemotingServices.uri_hash[identity.ObjectUri] = identity;
}
}
// Token: 0x06002A7A RID: 10874 RVA: 0x00089B50 File Offset: 0x00087D50
internal static object GetProxyForRemoteObject(ObjRef objref, Type classToProxy)
{
ClientActivatedIdentity clientActivatedIdentity = RemotingServices.GetIdentityForUri(objref.URI) as ClientActivatedIdentity;
if (clientActivatedIdentity != null)
{
return clientActivatedIdentity.GetServerObject();
}
return RemotingServices.GetRemoteObject(objref, classToProxy);
}
// Token: 0x06002A7B RID: 10875 RVA: 0x00089B84 File Offset: 0x00087D84
internal static object GetRemoteObject(ObjRef objRef, Type proxyType)
{
object obj;
RemotingServices.GetOrCreateClientIdentity(objRef, proxyType, out obj);
return obj;
}
// Token: 0x06002A7C RID: 10876 RVA: 0x00089B9C File Offset: 0x00087D9C
internal static object GetServerObject(string uri)
{
ClientActivatedIdentity clientActivatedIdentity = RemotingServices.GetIdentityForUri(uri) as ClientActivatedIdentity;
if (clientActivatedIdentity == null)
{
throw new RemotingException("Server for uri '" + uri + "' not found");
}
return clientActivatedIdentity.GetServerObject();
}
// Token: 0x06002A7D RID: 10877 RVA: 0x00089BD8 File Offset: 0x00087DD8
internal static byte[] SerializeCallData(object obj)
{
LogicalCallContext logicalCallContext = CallContext.CreateLogicalCallContext(false);
if (logicalCallContext != null)
{
obj = new RemotingServices.CACD
{
d = obj,
c = logicalCallContext
};
}
if (obj == null)
{
return null;
}
MemoryStream memoryStream = new MemoryStream();
RemotingServices._serializationFormatter.Serialize(memoryStream, obj);
return memoryStream.ToArray();
}
// Token: 0x06002A7E RID: 10878 RVA: 0x00089C2C File Offset: 0x00087E2C
internal static object DeserializeCallData(byte[] array)
{
if (array == null)
{
return null;
}
MemoryStream memoryStream = new MemoryStream(array);
object obj = RemotingServices._deserializationFormatter.Deserialize(memoryStream);
if (obj is RemotingServices.CACD)
{
RemotingServices.CACD cacd = (RemotingServices.CACD)obj;
obj = cacd.d;
CallContext.UpdateCurrentCallContext((LogicalCallContext)cacd.c);
}
return obj;
}
// Token: 0x06002A7F RID: 10879 RVA: 0x00089C80 File Offset: 0x00087E80
internal static byte[] SerializeExceptionData(Exception ex)
{
byte[] array;
try
{
int num = 4;
do
{
try
{
MemoryStream memoryStream = new MemoryStream();
RemotingServices._serializationFormatter.Serialize(memoryStream, ex);
return memoryStream.ToArray();
}
catch (Exception ex2)
{
if (ex2 is ThreadAbortException)
{
Thread.ResetAbort();
num = 5;
ex = ex2;
}
else if (num == 2)
{
ex = new Exception();
ex.SetMessage(ex2.Message);
ex.SetStackTrace(ex2.StackTrace);
}
else
{
ex = ex2;
}
}
num--;
}
while (num > 0);
array = null;
}
catch (Exception ex3)
{
byte[] array2 = RemotingServices.SerializeExceptionData(ex3);
Thread.ResetAbort();
array = array2;
}
return array;
}
// Token: 0x06002A80 RID: 10880 RVA: 0x00089D6C File Offset: 0x00087F6C
internal static object GetDomainProxy(AppDomain domain)
{
byte[] array = null;
Context currentContext = Thread.CurrentContext;
try
{
array = (byte[])AppDomain.InvokeInDomain(domain, typeof(AppDomain).GetMethod("GetMarshalledDomainObjRef", BindingFlags.Instance | BindingFlags.NonPublic), domain, null);
}
finally
{
AppDomain.InternalSetContext(currentContext);
}
byte[] array2 = new byte[array.Length];
array.CopyTo(array2, 0);
MemoryStream memoryStream = new MemoryStream(array2);
ObjRef objRef = (ObjRef)CADSerializer.DeserializeObject(memoryStream);
return (AppDomain)RemotingServices.Unmarshal(objRef);
}
// Token: 0x06002A81 RID: 10881 RVA: 0x00089E00 File Offset: 0x00088000
private static void RegisterInternalChannels()
{
CrossAppDomainChannel.RegisterCrossAppDomainChannel();
}
// Token: 0x06002A82 RID: 10882 RVA: 0x00089E08 File Offset: 0x00088008
internal static void DisposeIdentity(Identity ident)
{
Hashtable hashtable = RemotingServices.uri_hash;
lock (hashtable)
{
if (!ident.Disposed)
{
ClientIdentity clientIdentity = ident as ClientIdentity;
if (clientIdentity != null)
{
RemotingServices.uri_hash.Remove(RemotingServices.GetNormalizedUri(clientIdentity.TargetUri));
}
else
{
RemotingServices.uri_hash.Remove(ident.ObjectUri);
}
ident.Disposed = true;
}
}
}
// Token: 0x06002A83 RID: 10883 RVA: 0x00089E94 File Offset: 0x00088094
internal static Identity GetMessageTargetIdentity(IMessage msg)
{
if (msg is IInternalMessage)
{
return ((IInternalMessage)msg).TargetIdentity;
}
Hashtable hashtable = RemotingServices.uri_hash;
Identity identity;
lock (hashtable)
{
string normalizedUri = RemotingServices.GetNormalizedUri(((IMethodMessage)msg).Uri);
identity = RemotingServices.uri_hash[normalizedUri] as ServerIdentity;
}
return identity;
}
// Token: 0x06002A84 RID: 10884 RVA: 0x00089F14 File Offset: 0x00088114
internal static void SetMessageTargetIdentity(IMessage msg, Identity ident)
{
if (msg is IInternalMessage)
{
((IInternalMessage)msg).TargetIdentity = ident;
}
}
// Token: 0x06002A85 RID: 10885 RVA: 0x00089F30 File Offset: 0x00088130
internal static bool UpdateOutArgObject(ParameterInfo pi, object local, object remote)
{
if (pi.ParameterType.IsArray && ((Array)local).Rank == 1)
{
Array array = (Array)local;
if (array.Rank == 1)
{
Array.Copy((Array)remote, array, array.Length);
return true;
}
}
return false;
}
// Token: 0x06002A86 RID: 10886 RVA: 0x00089F88 File Offset: 0x00088188
private static string GetNormalizedUri(string uri)
{
if (uri.StartsWith("/"))
{
return uri.Substring(1);
}
return uri;
}
// Token: 0x04001041 RID: 4161
private static Hashtable uri_hash = new Hashtable();
// Token: 0x04001042 RID: 4162
private static BinaryFormatter _serializationFormatter;
// Token: 0x04001043 RID: 4163
private static BinaryFormatter _deserializationFormatter;
// Token: 0x04001044 RID: 4164
internal static string app_id;
// Token: 0x04001045 RID: 4165
private static int next_id = 1;
// Token: 0x04001046 RID: 4166
private static readonly BindingFlags methodBindings = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
// Token: 0x04001047 RID: 4167
private static readonly MethodInfo FieldSetterMethod;
// Token: 0x04001048 RID: 4168
private static readonly MethodInfo FieldGetterMethod;
// Token: 0x0200044C RID: 1100
[Serializable]
private class CACD
{
// Token: 0x04001049 RID: 4169
public object d;
// Token: 0x0400104A RID: 4170
public object c;
}
}
}