コード例 #1
0
        /// <summary>
        /// Calls the named method, finding the one with the best match
        /// </summary>
        /// <returns>
        /// The return of static method call
        /// </returns>
        /// <param name='type'>
        /// Type.
        /// </param>
        /// <param name='name'>
        /// Name.
        /// </param>
        /// <param name='parameters'>
        /// Parameters.
        /// </param>
        public object CallMethod(object obj, string name, params object[] parameters)
        {
            // send request
            var req = new CLRCallMethodMessage(obj, name, parameters);

            CLRMessage.Write(_cout, req);

            // get response
            return(CLRMessage.ReadValue(_cin));
        }
コード例 #2
0
 /// <summary>
 /// Calls a method.
 /// </summary>
 /// <param name="req">Req.</param>
 private void HandleCallMethod(CLRCallMethodMessage req)
 {
     try
     {
         // get object
         var obj = ToLocalObject(req.Obj);
         // invoke
         var result = _api.CallMethod(obj, req.MethodName, req.Parameters);
         CLRMessage.WriteValue(_cout, result);
     }
     catch (TargetInvocationException te)
     {
         CLRMessage.WriteValue(_cout, te.GetBaseException());
     }
     catch (Exception e)
     {
         CLRMessage.WriteValue(_cout, e);
     }
 }