コード例 #1
0
        } // MarshalResponseArgMap


        private void GetArgMaps()
        {
            lock (this)
            {
                if (_inRefArgMap == null)
                {
                    int[] inRefArgMap        = null;
                    int[] outRefArgMap       = null;
                    int[] outOnlyArgMap      = null;
                    int[] nonRefOutArgMap    = null;
                    int[] marshalRequestMap  = null;
                    int[] marshalResponseMap = null;

                    ArgMapper.GetParameterMaps(Parameters,
                                               out inRefArgMap, out outRefArgMap, out outOnlyArgMap,
                                               out nonRefOutArgMap,
                                               out marshalRequestMap, out marshalResponseMap);

                    _inRefArgMap        = inRefArgMap;
                    _outRefArgMap       = outRefArgMap;
                    _outOnlyArgMap      = outOnlyArgMap;
                    _nonRefOutArgMap    = nonRefOutArgMap;
                    _marshalRequestMap  = marshalRequestMap;
                    _marshalResponseMap = marshalResponseMap;
                }
            }
        } // GetArgMaps
コード例 #2
0
        public void ServerCallback(IAsyncResult ar)
        {
            if (!(this._asyncEnd != (MethodInfo)null))
            {
                return;
            }
            RemotingMethodCachedData reflectionCachedData1 = InternalRemotingServices.GetReflectionCachedData((MethodBase)this._asyncEnd);
            RemotingMethodCachedData reflectionCachedData2 = InternalRemotingServices.GetReflectionCachedData(this._msg.MethodBase);

            ParameterInfo[] parameters = reflectionCachedData1.Parameters;
            object[]        objArray   = new object[parameters.Length];
            objArray[parameters.Length - 1] = (object)ar;
            object[] args = this._msg.Args;
            AsyncMessageHelper.GetOutArgs(reflectionCachedData2.Parameters, args, objArray);
            StackBuilderSink stackBuilderSink = new StackBuilderSink(this._serverObject);

            object[] outArgs1;
            object   ret = stackBuilderSink.PrivateProcessMessage(this._asyncEnd.MethodHandle, Message.CoerceArgs((MethodBase)this._asyncEnd, objArray, parameters), this._serverObject, out outArgs1);

            if (outArgs1 != null)
            {
                outArgs1 = ArgMapper.ExpandAsyncEndArgsToSyncArgs(reflectionCachedData2, outArgs1);
            }
            stackBuilderSink.CopyNonByrefOutArgsFromOriginalArgs(reflectionCachedData2, args, ref outArgs1);
            object[]           outArgs2           = outArgs1;
            int                argCount           = this._msg.ArgCount;
            LogicalCallContext logicalCallContext = Thread.CurrentThread.GetMutableExecutionContext().LogicalCallContext;
            IMethodCallMessage mcm = this._msg;

            this.AsyncProcessResponse((IMessage) new ReturnMessage(ret, outArgs2, argCount, logicalCallContext, mcm), (ITransportHeaders)null, (Stream)null);
        }
コード例 #3
0
        } // MarshalResponseArgMap


        private void GetArgMaps()
        {
            lock (this)
            {
                if (_inRefArgMap == null)
                {
                    ArgMapper.GetParameterMaps(Parameters,
                                               out _inRefArgMap, out _outRefArgMap, out _outOnlyArgMap,
                                               out _nonRefOutArgMap,
                                               out _marshalRequestMap, out _marshalResponseMap);
                }
            }
        } // GetArgMaps
コード例 #4
0
ファイル: channelsinkstacks.cs プロジェクト: ydunk/masters
        /// <include file='doc\ChannelSinkStacks.uex' path='docs/doc[@for="ServerChannelSinkStack.ServerCallback"]/*' />
        public void ServerCallback(IAsyncResult ar)
        {
            if (_asyncEnd != null)
            {
                RemotingMethodCachedData asyncEndCache = (RemotingMethodCachedData)
                                                         InternalRemotingServices.GetReflectionCachedData(_asyncEnd);

                MethodInfo syncMI = (MethodInfo)_msg.MethodBase;
                RemotingMethodCachedData syncCache = (RemotingMethodCachedData)
                                                     InternalRemotingServices.GetReflectionCachedData(syncMI);

                ParameterInfo[] paramList = asyncEndCache.Parameters;

                // construct list to pass into End
                Object[] parameters = new Object[paramList.Length];
                parameters[paramList.Length - 1] = ar; // last parameter is the async result

                Object[] syncMsgArgs = _msg.Args;

                // copy out and ref parameters to the parameters list
                AsyncMessageHelper.GetOutArgs(syncCache.Parameters, syncMsgArgs, parameters);

                Object[] outArgs;

                StackBuilderSink s           = new StackBuilderSink(_serverObject);
                Object           returnValue =
                    s.PrivateProcessMessage(_asyncEnd,
                                            System.Runtime.Remoting.Messaging.Message.CoerceArgs(_asyncEnd, parameters, paramList),
                                            _serverObject,
                                            0,
                                            false,
                                            out outArgs);

                // The outArgs list is associated with the EndXXX method. We need to make sure
                //   it is sized properly for the out args of the XXX method.
                if (outArgs != null)
                {
                    outArgs = ArgMapper.ExpandAsyncEndArgsToSyncArgs(syncCache, outArgs);
                }

                s.CopyNonByrefOutArgsFromOriginalArgs(syncCache, syncMsgArgs, ref outArgs);

                IMessage retMessage = new ReturnMessage(
                    returnValue, outArgs, _msg.ArgCount, CallContext.GetLogicalCallContext(), _msg);

                AsyncProcessResponse(retMessage, null, null);
            }
        } // ServerCallback
コード例 #5
0
 private void GetArgMaps()
 {
     lock (this)
     {
         if (this._inRefArgMap != null)
         {
             return;
         }
         int[] local_2 = (int[])null;
         int[] local_3 = (int[])null;
         int[] local_4 = (int[])null;
         int[] local_5 = (int[])null;
         int[] local_6 = (int[])null;
         int[] local_7 = (int[])null;
         ArgMapper.GetParameterMaps(this.Parameters, out local_2, out local_3, out local_4, out local_5, out local_6, out local_7);
         this._inRefArgMap        = local_2;
         this._outRefArgMap       = local_3;
         this._outOnlyArgMap      = local_4;
         this._nonRefOutArgMap    = local_5;
         this._marshalRequestMap  = local_6;
         this._marshalResponseMap = local_7;
     }
 }
コード例 #6
0
 public void ServerCallback(IAsyncResult ar)
 {
     if (this._asyncEnd != null)
     {
         RemotingMethodCachedData reflectionCachedData = InternalRemotingServices.GetReflectionCachedData(this._asyncEnd);
         MethodInfo mi = (MethodInfo)this._msg.MethodBase;
         RemotingMethodCachedData reflectionCachedData2 = InternalRemotingServices.GetReflectionCachedData(mi);
         ParameterInfo[]          parameters            = reflectionCachedData.Parameters;
         object[] array = new object[parameters.Length];
         array[parameters.Length - 1] = ar;
         object[] args = this._msg.Args;
         AsyncMessageHelper.GetOutArgs(reflectionCachedData2.Parameters, args, array);
         StackBuilderSink stackBuilderSink = new StackBuilderSink(this._serverObject);
         object[]         array2;
         object           ret = stackBuilderSink.PrivateProcessMessage(this._asyncEnd.MethodHandle, Message.CoerceArgs(this._asyncEnd, array, parameters), this._serverObject, out array2);
         if (array2 != null)
         {
             array2 = ArgMapper.ExpandAsyncEndArgsToSyncArgs(reflectionCachedData2, array2);
         }
         stackBuilderSink.CopyNonByrefOutArgsFromOriginalArgs(reflectionCachedData2, args, ref array2);
         IMessage msg = new ReturnMessage(ret, array2, this._msg.ArgCount, Thread.CurrentThread.GetMutableExecutionContext().LogicalCallContext, this._msg);
         this.AsyncProcessResponse(msg, null, null);
     }
 }
コード例 #7
0
 public void ServerCallback(IAsyncResult ar)
 {
     if (this._asyncEnd != null)
     {
         object[] objArray3;
         RemotingMethodCachedData reflectionCachedData = InternalRemotingServices.GetReflectionCachedData((MethodBase)this._asyncEnd);
         MethodInfo methodBase = (MethodInfo)this._msg.MethodBase;
         RemotingMethodCachedData syncMethod = InternalRemotingServices.GetReflectionCachedData((MethodBase)methodBase);
         ParameterInfo[]          parameters = reflectionCachedData.Parameters;
         object[] endArgs = new object[parameters.Length];
         endArgs[parameters.Length - 1] = ar;
         object[] args = this._msg.Args;
         AsyncMessageHelper.GetOutArgs(syncMethod.Parameters, args, endArgs);
         StackBuilderSink sink = new StackBuilderSink(this._serverObject);
         object           ret  = sink.PrivateProcessMessage(this._asyncEnd.MethodHandle, Message.CoerceArgs(this._asyncEnd, endArgs, parameters), this._serverObject, 0, false, out objArray3);
         if (objArray3 != null)
         {
             objArray3 = ArgMapper.ExpandAsyncEndArgsToSyncArgs(syncMethod, objArray3);
         }
         sink.CopyNonByrefOutArgsFromOriginalArgs(syncMethod, args, ref objArray3);
         IMessage msg = new ReturnMessage(ret, objArray3, this._msg.ArgCount, CallContext.GetLogicalCallContext(), this._msg);
         this.AsyncProcessResponse(msg, null, null);
     }
 }
コード例 #8
0
ファイル: Message.cs プロジェクト: sjyanxin/WPFSource
 public virtual String GetOutArgName(int index)
 { 
     if (_argMapper == null) _argMapper = new ArgMapper(this, true); 
     return _argMapper.GetArgName(index);
 } 
コード例 #9
0
ファイル: Message.cs プロジェクト: sjyanxin/WPFSource
 public virtual Object GetOutArg(int argNum) 
 { 
     if (_argMapper == null) _argMapper = new ArgMapper(this, true);
     return _argMapper.GetArg(argNum); 
 }
コード例 #10
0
ファイル: Message.cs プロジェクト: sjyanxin/WPFSource
 public virtual String GetInArgName(int index)
 { 
     if (_argMapper == null) _argMapper = new ArgMapper(this, false);
     return _argMapper.GetArgName(index);
 } // GetInArgName
コード例 #11
0
ファイル: Message.cs プロジェクト: sjyanxin/WPFSource
 public virtual Object GetInArg(int argNum) 
 {
     if (_argMapper == null) _argMapper = new ArgMapper(this, false);
     return _argMapper.GetArg(argNum);
 } // GetInArg 
コード例 #12
0
ファイル: Message.cs プロジェクト: sjyanxin/WPFSource
 public String GetOutArgName(int index)
 { 
     if (argMapper == null) argMapper = new ArgMapper(this, true);
     return argMapper.GetArgName(index);
 }
コード例 #13
0
ファイル: Message.cs プロジェクト: sjyanxin/WPFSource
 public Object GetOutArg(int argNum) 
 {
     if (argMapper == null) argMapper = new ArgMapper(this, true);
     return argMapper.GetArg(argNum);
 } 
コード例 #14
0
ファイル: Message.cs プロジェクト: sjyanxin/WPFSource
        //
        // SetObjectFromSoapData -- assumes SOAP format and populates the arguments array 
        //
 
        internal void SetObjectFromSoapData(SerializationInfo info) 
        {
            //SerializationInfoEnumerator e = info.GetEnumerator(); 

            Hashtable keyToNamespaceTable = (Hashtable)info.GetValue("__keyToNamespaceTable", typeof(Hashtable));
            ArrayList paramNames = (ArrayList)info.GetValue("__paramNameList", typeof(ArrayList));
            SoapFault soapFault = (SoapFault)info.GetValue("__fault", typeof(SoapFault)); 

            if (soapFault != null) 
                    { 
                ServerFault serverFault = soapFault.Detail as ServerFault;
                if (null != serverFault) 
                {
                    // Server Fault information
                    if (serverFault.Exception != null)
                        fault = serverFault.Exception; 
                    else
                    { 
                        Type exceptionType = Type.GetType(serverFault.ExceptionType, false, false); 
                        if (exceptionType == null)
                        { 
                            // Exception type cannot be resolved, use a ServerException
                            StringBuilder sb = new StringBuilder();
                            sb.Append("\nException Type: ");
                            sb.Append(serverFault.ExceptionType); 
                            sb.Append("\n");
                            sb.Append("Exception Message: "); 
                            sb.Append(serverFault.ExceptionMessage); 
                            sb.Append("\n");
                            sb.Append(serverFault.StackTrace); 
                            fault = new ServerException(sb.ToString());
                        }
                        else
                        { 
                            // Exception type can be resolved, throw the exception
                            Object[] args = {serverFault.ExceptionMessage}; 
                            fault = (Exception)Activator.CreateInstance( 
                                                    exceptionType,
                                                    BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.CreateInstance, 
                                                    null,
                                                    args,
                                                    null,
                                                    null); 
                        }
                    } 
                } 
                else if ((soapFault.Detail != null) && (soapFault.Detail.GetType() == typeof(String)) && (!(((String)soapFault.Detail).Length == 0)))
                { 
                    fault = new ServerException((String)soapFault.Detail);
                }
                else
                { 
                    fault = new ServerException(soapFault.FaultString);
                } 
 
                return;
            } 

            MethodInfo mi = MI as MethodInfo;
            int paramNameIndex = 0;
            if (mi != null) 
            {
                Type retType = mi.ReturnType; 
                if (retType != typeof(void)) 
                {
                    paramNameIndex++; 
                    Object returnValue = info.GetValue((String)paramNames[0], typeof(Object));
                    if (returnValue is String)
                        retVal = Message.SoapCoerceArg(returnValue, retType, keyToNamespaceTable);
                    else 
                        retVal = returnValue;
                } 
            } 

            // populate the args array 
            ParameterInfo[] pinfos = _methodCache.Parameters;

            Object fUnordered = (InternalProperties == null) ? null : InternalProperties["__UnorderedParams"];
            if (fUnordered != null && 
                (fUnordered is System.Boolean) &&
                (true == (bool)fUnordered)) 
            { 
                // Unordered
                for (int i=paramNameIndex; i<paramNames.Count; i++) 
                {
                    String memberName = (String)paramNames[i];

                    // check for the parameter name 

                    int position = -1; 
                    for (int j=0; j<pinfos.Length; j++) 
                    {
                        if (memberName.Equals(pinfos[j].Name)) 
                        {
                            position = pinfos[j].Position;
                        }
                    } 

                    // no name so check for well known name 
 
                    if (position == -1)
                    { 
                        if (!memberName.StartsWith("__param", StringComparison.Ordinal))
                        {
                            throw new RemotingException(
                                Environment.GetResourceString( 
                                    "Remoting_Message_BadSerialization"));
                        } 
                        position = Int32.Parse(memberName.Substring(7), CultureInfo.InvariantCulture); 
                    }
 
                    // if still not resolved then throw

                    if (position >= argCount)
                    { 
                        throw new RemotingException(
                            Environment.GetResourceString( 
                                "Remoting_Message_BadSerialization")); 
                    }
 
                    // store the arg in the parameter array

                    if (outArgs == null)
                    { 
                        outArgs = new Object[argCount];
                    } 
                    outArgs[position]= Message.SoapCoerceArg(info.GetValue(memberName, typeof(Object)), pinfos[position].ParameterType, keyToNamespaceTable); 
                }
            } 
            else
            {
                // ordered
                if (argMapper == null) argMapper = new ArgMapper(this, true); 
                for (int j=paramNameIndex; j<paramNames.Count; j++)
                { 
                    String memberName = (String)paramNames[j]; 
                    if (outArgs == null)
                    { 
                        outArgs = new Object[argCount];
                    }

                    int position = argMapper.Map[j-paramNameIndex]; 
                    outArgs[position] = Message.SoapCoerceArg(info.GetValue(memberName, typeof(Object)), pinfos[position].ParameterType, keyToNamespaceTable);
                } 
            } 
        } // SetObjectFromSoapData
コード例 #15
0
ファイル: Message.cs プロジェクト: sjyanxin/WPFSource
        [System.Security.SecurityCritical]  // auto-generated
        public virtual Object HeaderHandler(Header[] h)
        {
            SerializationMonkey m = (SerializationMonkey) FormatterServices.GetUninitializedObject(typeof(SerializationMonkey)); 
            Header[] newHeaders = null;
            if (h != null && h.Length > 0 && h[0].Name == "__methodName") 
            { 
                methodName = (String)h[0].Value;
                if (h.Length > 1) 
                {
                    newHeaders = new Header[h.Length -1];
                    Array.Copy(h, 1, newHeaders, 0, h.Length-1);
                } 
                else
                    newHeaders = null; 
            } 
            else
                newHeaders = h; 

            FillHeaders(newHeaders, true);
            ResolveMethod(false);
            m._obj = this; 
            if (MI != null)
            { 
                ArgMapper argm = new ArgMapper(MI, false); 
                m.fieldNames = argm.ArgNames;
                m.fieldTypes = argm.ArgTypes; 
            }
            return m;
        }
コード例 #16
0
ファイル: Message.cs プロジェクト: sjyanxin/WPFSource
 public Object GetInArg(int argNum)
 { 
     if (argMapper == null) argMapper = new ArgMapper(this, false);
     return argMapper.GetArg(argNum);
 }