private object[] WriteMethodCall(IMethodCallMessage mcm)
        {
            string uri             = mcm.Uri;
            string methodName      = mcm.MethodName;
            string typeName        = mcm.TypeName;
            object methodSignature = (object)null;

            object[] properties = (object[])null;
            Type[]   instArgs   = (Type[])null;
            if (mcm.MethodBase.IsGenericMethod)
            {
                instArgs = mcm.MethodBase.GetGenericArguments();
            }
            object[]         args            = mcm.Args;
            IInternalMessage internalMessage = mcm as IInternalMessage;

            if (internalMessage == null || internalMessage.HasProperties())
            {
                properties = ObjectWriter.StoreUserPropertiesForMethodMessage((IMethodMessage)mcm);
            }
            if (mcm.MethodSignature != null && RemotingServices.IsMethodOverloaded((IMethodMessage)mcm))
            {
                methodSignature = mcm.MethodSignature;
            }
            LogicalCallContext logicalCallContext = mcm.LogicalCallContext;
            object             callContext        = logicalCallContext != null ? (!logicalCallContext.HasInfo ? (object)logicalCallContext.RemotingData.LogicalCallID : (object)logicalCallContext) : (object)null;

            return(this.serWriter.WriteCallArray(uri, methodName, typeName, instArgs, args, methodSignature, callContext, properties));
        }
        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();
            }
        }
Example #3
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
Example #4
0
        internal void PropagateIncomingHeadersToCallContext(IMessage msg)
        {
            IInternalMessage internalMessage = msg as IInternalMessage;

            if (internalMessage != null && !internalMessage.HasProperties())
            {
                return;
            }
            IDictionary           properties = msg.Properties;
            IDictionaryEnumerator enumerator = properties.GetEnumerator();
            int num = 0;

            while (enumerator.MoveNext())
            {
                string text = (string)enumerator.Key;
                if (!text.StartsWith("__", StringComparison.Ordinal) && enumerator.Value is Header)
                {
                    num++;
                }
            }
            Header[] array = null;
            if (num > 0)
            {
                array = new Header[num];
                num   = 0;
                enumerator.Reset();
                while (enumerator.MoveNext())
                {
                    string text2 = (string)enumerator.Key;
                    if (!text2.StartsWith("__", StringComparison.Ordinal))
                    {
                        Header header = enumerator.Value as Header;
                        if (header != null)
                        {
                            array[num++] = header;
                        }
                    }
                }
            }
            this._recvHeaders = array;
            this._sendHeaders = null;
        }
Example #5
0
        private object[] WriteMethodCall(IMethodCallMessage mcm)
        {
            string uri             = mcm.Uri;
            string methodName      = mcm.MethodName;
            string typeName        = mcm.TypeName;
            object methodSignature = null;
            object callContext     = null;

            object[] properties = null;
            Type[]   instArgs   = null;
            if (mcm.MethodBase.IsGenericMethod)
            {
                instArgs = mcm.MethodBase.GetGenericArguments();
            }
            object[]         args    = mcm.Args;
            IInternalMessage message = mcm as IInternalMessage;

            if ((message == null) || message.HasProperties())
            {
                properties = StoreUserPropertiesForMethodMessage(mcm);
            }
            if ((mcm.MethodSignature != null) && RemotingServices.IsMethodOverloaded(mcm))
            {
                methodSignature = mcm.MethodSignature;
            }
            LogicalCallContext logicalCallContext = mcm.LogicalCallContext;

            if (logicalCallContext == null)
            {
                callContext = null;
            }
            else if (logicalCallContext.HasInfo)
            {
                callContext = logicalCallContext;
            }
            else
            {
                callContext = logicalCallContext.RemotingData.LogicalCallID;
            }
            return(this.serWriter.WriteCallArray(uri, methodName, typeName, instArgs, args, methodSignature, callContext, properties));
        }
        internal void PropagateIncomingHeadersToCallContext(IMessage msg)
        {
            IInternalMessage message = msg as IInternalMessage;

            if ((message == null) || message.HasProperties())
            {
                IDictionaryEnumerator enumerator = msg.Properties.GetEnumerator();
                int num = 0;
                while (enumerator.MoveNext())
                {
                    string key = (string)enumerator.Key;
                    if (!key.StartsWith("__", StringComparison.Ordinal) && (enumerator.Value is Header))
                    {
                        num++;
                    }
                }
                Header[] headerArray = null;
                if (num > 0)
                {
                    headerArray = new Header[num];
                    num         = 0;
                    enumerator.Reset();
                    while (enumerator.MoveNext())
                    {
                        string str2 = (string)enumerator.Key;
                        if (!str2.StartsWith("__", StringComparison.Ordinal))
                        {
                            Header header = enumerator.Value as Header;
                            if (header != null)
                            {
                                headerArray[num++] = header;
                            }
                        }
                    }
                }
                this._recvHeaders = headerArray;
                this._sendHeaders = null;
            }
        }
Example #7
0
        internal void PropagateIncomingHeadersToCallContext(IMessage msg)
        {
            IInternalMessage internalMessage = msg as IInternalMessage;

            if (internalMessage != null && !internalMessage.HasProperties())
            {
                return;
            }
            IDictionaryEnumerator enumerator = msg.Properties.GetEnumerator();
            int length = 0;

            while (enumerator.MoveNext())
            {
                if (!((string)enumerator.Key).StartsWith("__", StringComparison.Ordinal) && enumerator.Value is Header)
                {
                    ++length;
                }
            }
            Header[] headerArray = (Header[])null;
            if (length > 0)
            {
                headerArray = new Header[length];
                int num = 0;
                enumerator.Reset();
                while (enumerator.MoveNext())
                {
                    if (!((string)enumerator.Key).StartsWith("__", StringComparison.Ordinal))
                    {
                        Header header = enumerator.Value as Header;
                        if (header != null)
                        {
                            headerArray[num++] = header;
                        }
                    }
                }
            }
            this._recvHeaders = headerArray;
            this._sendHeaders = (Header[])null;
        }
Example #8
0
        [System.Security.SecurityCritical]  // auto-generated
        internal void PropagateIncomingHeadersToCallContext(IMessage msg)
        {
            BCLDebug.Assert(msg != null, "Why is the message null?");

            // If it's an internal message, we can quickly tell if there are any
            //   headers.
            IInternalMessage iim = msg as IInternalMessage;

            if (iim != null)
            {
                if (!iim.HasProperties())
                {
                    // If there are no properties just return immediately.
                    return;
                }
            }

            IDictionary properties = msg.Properties;

            BCLDebug.Assert(properties != null, "Why are the properties null?");

            IDictionaryEnumerator e = (IDictionaryEnumerator)properties.GetEnumerator();

            // cycle through the properties to get a count of the headers
            int count = 0;

            while (e.MoveNext())
            {
                String key = (String)e.Key;
                if (!key.StartsWith("__", StringComparison.Ordinal))
                {
                    // We don't want to have to check for special values, so we
                    //   blanketly state that header names can't start with
                    //   double underscore.
                    if (e.Value is Header)
                    {
                        count++;
                    }
                }
            }

            // If there are headers, create array and set it to the received header property
            Header[] headers = null;
            if (count > 0)
            {
                headers = new Header[count];

                count = 0;
                e.Reset();
                while (e.MoveNext())
                {
                    String key = (String)e.Key;
                    if (!key.StartsWith("__", StringComparison.Ordinal))
                    {
                        Header header = e.Value as Header;
                        if (header != null)
                        {
                            headers[count++] = header;
                        }
                    }
                }
            }

            _recvHeaders = headers;
            _sendHeaders = null;
        } // PropagateIncomingHeadersToCallContext