private SmuggledMethodCallMessage(IMethodCallMessage mcm)
        {
            this._uri        = mcm.Uri;
            this._methodName = mcm.MethodName;
            this._typeName   = mcm.TypeName;
            ArrayList        arrayList       = null;
            IInternalMessage internalMessage = mcm as IInternalMessage;

            if (internalMessage == null || internalMessage.HasProperties())
            {
                this._propertyCount = MessageSmuggler.StoreUserPropertiesForMethodMessage(mcm, ref arrayList);
            }
            if (mcm.MethodBase.IsGenericMethod)
            {
                Type[] genericArguments = mcm.MethodBase.GetGenericArguments();
                if (genericArguments != null && genericArguments.Length != 0)
                {
                    if (arrayList == null)
                    {
                        arrayList = new ArrayList();
                    }
                    this._instantiation = new MessageSmuggler.SerializedArg(arrayList.Count);
                    arrayList.Add(genericArguments);
                }
            }
            if (RemotingServices.IsMethodOverloaded(mcm))
            {
                if (arrayList == null)
                {
                    arrayList = new ArrayList();
                }
                this._methodSignature = new MessageSmuggler.SerializedArg(arrayList.Count);
                arrayList.Add(mcm.MethodSignature);
            }
            LogicalCallContext logicalCallContext = mcm.LogicalCallContext;

            if (logicalCallContext == null)
            {
                this._callContext = null;
            }
            else if (logicalCallContext.HasInfo)
            {
                if (arrayList == null)
                {
                    arrayList = new ArrayList();
                }
                this._callContext = new MessageSmuggler.SerializedArg(arrayList.Count);
                arrayList.Add(logicalCallContext);
            }
            else
            {
                this._callContext = logicalCallContext.RemotingData.LogicalCallID;
            }
            this._args = MessageSmuggler.FixupArgs(mcm.Args, ref arrayList);
            if (arrayList != null)
            {
                MemoryStream memoryStream = CrossAppDomainSerializer.SerializeMessageParts(arrayList);
                this._serializedArgs = memoryStream.GetBuffer();
            }
        }
Beispiel #2
0
 protected static object[] FixupArgs(object[] args, ref ArrayList argsToSerialize)
 {
     object[] objArray = new object[args.Length];
       int length = args.Length;
       for (int index = 0; index < length; ++index)
     objArray[index] = MessageSmuggler.FixupArg(args[index], ref argsToSerialize);
       return objArray;
 }
Beispiel #3
0
 protected static object[] UndoFixupArgs(object[] args, ArrayList deserializedArgs)
 {
     object[] objArray = new object[args.Length];
       int length = args.Length;
       for (int index = 0; index < length; ++index)
     objArray[index] = MessageSmuggler.UndoFixupArg(args[index], deserializedArgs);
       return objArray;
 }
        protected static object FixupArg(object arg, ref ArrayList argsToSerialize)
        {
            if (arg == null)
            {
                return(null);
            }
            MarshalByRefObject marshalByRefObject = arg as MarshalByRefObject;
            int count;

            if (marshalByRefObject != null)
            {
                if (!RemotingServices.IsTransparentProxy(marshalByRefObject) || RemotingServices.GetRealProxy(marshalByRefObject) is RemotingProxy)
                {
                    ObjRef objRef = RemotingServices.MarshalInternal(marshalByRefObject, null, null);
                    if (objRef.CanSmuggle())
                    {
                        if (!RemotingServices.IsTransparentProxy(marshalByRefObject))
                        {
                            ServerIdentity serverIdentity = (ServerIdentity)MarshalByRefObject.GetIdentity(marshalByRefObject);
                            serverIdentity.SetHandle();
                            objRef.SetServerIdentity(serverIdentity.GetHandle());
                            objRef.SetDomainID(AppDomain.CurrentDomain.GetId());
                        }
                        ObjRef objRef2 = objRef.CreateSmuggleableCopy();
                        objRef2.SetMarshaledObject();
                        return(new SmuggledObjRef(objRef2));
                    }
                }
                if (argsToSerialize == null)
                {
                    argsToSerialize = new ArrayList();
                }
                count = argsToSerialize.Count;
                argsToSerialize.Add(arg);
                return(new MessageSmuggler.SerializedArg(count));
            }
            if (MessageSmuggler.CanSmuggleObjectDirectly(arg))
            {
                return(arg);
            }
            Array array = arg as Array;

            if (array != null)
            {
                Type elementType = array.GetType().GetElementType();
                if (elementType.IsPrimitive || elementType == typeof(string))
                {
                    return(array.Clone());
                }
            }
            if (argsToSerialize == null)
            {
                argsToSerialize = new ArrayList();
            }
            count = argsToSerialize.Count;
            argsToSerialize.Add(arg);
            return(new MessageSmuggler.SerializedArg(count));
        }
        protected static object[] UndoFixupArgs(object[] args, ArrayList deserializedArgs)
        {
            object[] array = new object[args.Length];
            int      num   = args.Length;

            for (int i = 0; i < num; i++)
            {
                array[i] = MessageSmuggler.UndoFixupArg(args[i], deserializedArgs);
            }
            return(array);
        }
        protected static object[] FixupArgs(object[] args, ref ArrayList argsToSerialize)
        {
            object[] array = new object[args.Length];
            int      num   = args.Length;

            for (int i = 0; i < num; i++)
            {
                array[i] = MessageSmuggler.FixupArg(args[i], ref argsToSerialize);
            }
            return(array);
        }
        private SmuggledMethodReturnMessage(IMethodReturnMessage mrm)
        {
            ArrayList     argsToSerialize = (ArrayList)null;
            ReturnMessage returnMessage   = mrm as ReturnMessage;

            if (returnMessage == null || returnMessage.HasProperties())
            {
                this._propertyCount = MessageSmuggler.StoreUserPropertiesForMethodMessage((IMethodMessage)mrm, ref argsToSerialize);
            }
            Exception exception = mrm.Exception;

            if (exception != null)
            {
                if (argsToSerialize == null)
                {
                    argsToSerialize = new ArrayList();
                }
                this._exception = new MessageSmuggler.SerializedArg(argsToSerialize.Count);
                argsToSerialize.Add((object)exception);
            }
            LogicalCallContext logicalCallContext = mrm.LogicalCallContext;

            if (logicalCallContext == null)
            {
                this._callContext = (object)null;
            }
            else if (logicalCallContext.HasInfo)
            {
                if (logicalCallContext.Principal != null)
                {
                    logicalCallContext.Principal = (IPrincipal)null;
                }
                if (argsToSerialize == null)
                {
                    argsToSerialize = new ArrayList();
                }
                this._callContext = (object)new MessageSmuggler.SerializedArg(argsToSerialize.Count);
                argsToSerialize.Add((object)logicalCallContext);
            }
            else
            {
                this._callContext = (object)logicalCallContext.RemotingData.LogicalCallID;
            }
            this._returnValue = MessageSmuggler.FixupArg(mrm.ReturnValue, ref argsToSerialize);
            this._args        = MessageSmuggler.FixupArgs(mrm.Args, ref argsToSerialize);
            if (argsToSerialize == null)
            {
                return;
            }
            this._serializedArgs = CrossAppDomainSerializer.SerializeMessageParts(argsToSerialize).GetBuffer();
        }
Beispiel #8
0
 internal object[] GetArgs(ArrayList deserializedArgs)
 {
     return(MessageSmuggler.UndoFixupArgs(this._args, deserializedArgs));
 }
Beispiel #9
0
 internal object GetReturnValue(ArrayList deserializedArgs)
 {
     return(MessageSmuggler.UndoFixupArg(this._returnValue, deserializedArgs));
 }