Beispiel #1
0
        private SmuggledMethodCallMessage(IMethodCallMessage mcm)
        {
            _uri        = mcm.Uri;
            _methodName = mcm.MethodName;
            _typeName   = mcm.TypeName;

            ArrayList argsToSerialize = null;

            IInternalMessage iim = mcm as IInternalMessage;

            // user properties (everything but special entries)
            if ((iim == null) || iim.HasProperties())
            {
                _propertyCount = StoreUserPropertiesForMethodMessage(mcm, ref argsToSerialize);
            }

            // handle method signature
            if (RemotingServices.IsMethodOverloaded(mcm))
            {
                if (argsToSerialize == null)
                {
                    argsToSerialize = new ArrayList();
                }
                _methodSignature = new SerializedArg(argsToSerialize.Count);
                argsToSerialize.Add(mcm.MethodSignature);
            }

            // handle call context
            LogicalCallContext lcc = mcm.LogicalCallContext;

            if (lcc == null)
            {
                _callContext = null;
            }
            else
            if (lcc.HasInfo)
            {
                if (argsToSerialize == null)
                {
                    argsToSerialize = new ArrayList();
                }
                _callContext = new SerializedArg(argsToSerialize.Count);
                argsToSerialize.Add(lcc);
            }
            else
            {
                // just smuggle the call id string
                _callContext = lcc.RemotingData.LogicalCallID;
            }

            _args = FixupArgs(mcm.Args, ref argsToSerialize);

            if (argsToSerialize != null)
            {
                //MemoryStream argStm = CrossAppDomainSerializer.SerializeMessageParts(argsToSerialize, out _serializerSmuggledArgs);
                MemoryStream argStm = CrossAppDomainSerializer.SerializeMessageParts(argsToSerialize);
                _serializedArgs = argStm.GetBuffer();
            }
        } // SmuggledMethodCallMessage
        [System.Security.SecurityCritical]  // auto-generated
        private SmuggledMethodReturnMessage(IMethodReturnMessage mrm)
        {           
            ArrayList argsToSerialize = null;
            
            ReturnMessage retMsg = mrm as ReturnMessage;

            // user properties (everything but special entries)
            if ((retMsg == null) || retMsg.HasProperties())
                _propertyCount = StoreUserPropertiesForMethodMessage(mrm, ref argsToSerialize);

            // handle exception
            Exception excep = mrm.Exception;
            if (excep != null)
            {
                if (argsToSerialize == null)
                    argsToSerialize = new ArrayList();
                _exception = new SerializedArg(argsToSerialize.Count);
                argsToSerialize.Add(excep);
            }

            // handle call context
            LogicalCallContext lcc = mrm.LogicalCallContext;
            if (lcc == null)
            {
                _callContext = null;
            }
            else
            if (lcc.HasInfo)
            {
                if (lcc.Principal != null)
                    lcc.Principal = null;
            
                if (argsToSerialize == null)
                    argsToSerialize = new ArrayList();
                _callContext = new SerializedArg(argsToSerialize.Count);
                argsToSerialize.Add(lcc);
            }
            else
            {
                // just smuggle the call id string
                _callContext = lcc.RemotingData.LogicalCallID;
            }
            
            _returnValue = FixupArg(mrm.ReturnValue, ref argsToSerialize);
            _args = FixupArgs(mrm.Args, ref argsToSerialize);

            if (argsToSerialize != null)
            {
                MemoryStream argStm = CrossAppDomainSerializer.SerializeMessageParts(argsToSerialize);
                //MemoryStream argStm = CrossAppDomainSerializer.SerializeMessageParts(argsToSerialize, out _serializerSmuggledArgs);
                _serializedArgs = argStm.GetBuffer();
            }          

        } // SmuggledMethodReturnMessage
        protected static object UndoFixupArg(object arg, ArrayList deserializedArgs)
        {
            SmuggledObjRef ref2 = arg as SmuggledObjRef;

            if (ref2 != null)
            {
                return(ref2.ObjRef.GetRealObjectHelper());
            }
            SerializedArg arg2 = arg as SerializedArg;

            if (arg2 != null)
            {
                return(deserializedArgs[arg2.Index]);
            }
            return(arg);
        }
        [System.Security.SecurityCritical]  // auto-generated
        protected static Object UndoFixupArg(Object arg, ArrayList deserializedArgs)
        {
            SmuggledObjRef smuggledObjRef = arg as SmuggledObjRef;
            if (smuggledObjRef != null)
            {
                // We call GetRealObject here ... that covers any
                // special unmarshaling we need to do for _ComObject
                return smuggledObjRef.ObjRef.GetRealObjectHelper();
            }

            SerializedArg serializedArg = arg as SerializedArg;
            if (serializedArg != null)
            {
                return deserializedArgs[serializedArg.Index];
            }
            
            return arg;
        } // UndoFixupArg
Beispiel #5
0
        [System.Security.SecurityCritical]  // auto-generated 
        private SmuggledMethodReturnMessage(IMethodReturnMessage mrm)
        {
            ArrayList argsToSerialize = null;
 
            ReturnMessage retMsg = mrm as ReturnMessage;
 
            // user properties (everything but special entries) 
            if ((retMsg == null) || retMsg.HasProperties())
                _propertyCount = StoreUserPropertiesForMethodMessage(mrm, ref argsToSerialize); 

            // handle exception
            Exception excep = mrm.Exception;
            if (excep != null) 
            {
                if (argsToSerialize == null) 
                    argsToSerialize = new ArrayList(); 
                _exception = new SerializedArg(argsToSerialize.Count);
                argsToSerialize.Add(excep); 
            }

            // handle call context
            LogicalCallContext lcc = mrm.LogicalCallContext; 
            if (lcc == null)
            { 
                _callContext = null; 
            }
            else 
            if (lcc.HasInfo)
            {
                if (lcc.Principal != null)
                    lcc.Principal = null; 

                if (argsToSerialize == null) 
                    argsToSerialize = new ArrayList(); 
                _callContext = new SerializedArg(argsToSerialize.Count);
                argsToSerialize.Add(lcc); 
            }
            else
            {
                // just smuggle the call id string 
                _callContext = lcc.RemotingData.LogicalCallID;
            } 
 
            _returnValue = FixupArg(mrm.ReturnValue, ref argsToSerialize);
            _args = FixupArgs(mrm.Args, ref argsToSerialize); 

            if (argsToSerialize != null)
            {
                MemoryStream argStm = CrossAppDomainSerializer.SerializeMessageParts(argsToSerialize); 
                //MemoryStream argStm = CrossAppDomainSerializer.SerializeMessageParts(argsToSerialize, out _serializerSmuggledArgs);
                _serializedArgs = argStm.GetBuffer(); 
            } 

        } // SmuggledMethodReturnMessage 
Beispiel #6
0
        [System.Security.SecurityCritical]  // auto-generated 
        private SmuggledMethodCallMessage(IMethodCallMessage mcm) 
        {
            _uri = mcm.Uri; 
            _methodName = mcm.MethodName;
            _typeName = mcm.TypeName;

            ArrayList argsToSerialize = null; 

            IInternalMessage iim = mcm as IInternalMessage; 
 
            // user properties (everything but special entries)
            if ((iim == null) || iim.HasProperties()) 
                _propertyCount = StoreUserPropertiesForMethodMessage(mcm, ref argsToSerialize);

            // generic instantiation information
            if (mcm.MethodBase.IsGenericMethod) 
            {
                Type[] inst = mcm.MethodBase.GetGenericArguments(); 
                if (inst != null && inst.Length > 0) 
                {
                    if (argsToSerialize == null) 
                        argsToSerialize = new ArrayList();
                    _instantiation = new SerializedArg(argsToSerialize.Count);
                    argsToSerialize.Add(inst);
                } 
            }
 
            // handle method signature 
            if (RemotingServices.IsMethodOverloaded(mcm))
            { 
                if (argsToSerialize == null)
                    argsToSerialize = new ArrayList();
                _methodSignature = new SerializedArg(argsToSerialize.Count);
                argsToSerialize.Add(mcm.MethodSignature); 
            }
 
            // handle call context 
            LogicalCallContext lcc = mcm.LogicalCallContext;
            if (lcc == null) 
            {
                _callContext = null;
            }
            else 
            if (lcc.HasInfo)
            { 
                if (argsToSerialize == null) 
                    argsToSerialize = new ArrayList();
                _callContext = new SerializedArg(argsToSerialize.Count); 
                argsToSerialize.Add(lcc);
            }
            else
            { 
                // just smuggle the call id string
                _callContext = lcc.RemotingData.LogicalCallID; 
            } 

            _args = FixupArgs(mcm.Args, ref argsToSerialize); 

            if (argsToSerialize != null)
            {
                //MemoryStream argStm = CrossAppDomainSerializer.SerializeMessageParts(argsToSerialize, out _serializerSmuggledArgs); 
                MemoryStream argStm = CrossAppDomainSerializer.SerializeMessageParts(argsToSerialize);
                _serializedArgs = argStm.GetBuffer(); 
            } 

        } // SmuggledMethodCallMessage