コード例 #1
0
ファイル: Proxy.cs プロジェクト: erisonliang/FastIpc
        /// <summary>Runs a (void) method on the object being proxied. This works on both the local and remote side.</summary>
        public Task Run(Expression <Action <TRemote> > remoteMethod)
        {
            var li = LocalInstance;

            if (li != null)
            {
                try
                {
                    var fastEval = FastIpc.FastEvalExpr <TRemote, object>(remoteMethod.Body);
                    if (fastEval != null)
                    {
                        fastEval(li);
                    }
                    else
                    {
                        remoteMethod.Compile()(li);
                    }
                    return(Task.FromResult(false));
                }
                catch (Exception ex)
                {
                    return(Task.FromException(ex));
                }
            }
            return(SendMethodCall <object>(remoteMethod.Body, false));
        }
コード例 #2
0
ファイル: Proxy.cs プロジェクト: erisonliang/FastIpc
        /// <summary>Runs a non-void method on the object being proxied. This works on both the local and remote side.
        /// Use this overload for methods on the other domain that are themselves asynchronous.</summary>
        public Task <TResult> Eval <TResult>(Expression <Func <TRemote, Task <TResult> > > remoteMethod)
        {
            var li = LocalInstance;

            if (li != null)
            {
                try
                {
                    var fastEval = FastIpc.FastEvalExpr <TRemote, Task <TResult> >(remoteMethod.Body);
                    if (fastEval != null)
                    {
                        return(fastEval(li));
                    }
                    return(remoteMethod.Compile()(li));
                }
                catch (Exception ex)
                {
                    return(Task.FromException <TResult>(ex));
                }
            }
            return(SendMethodCall <TResult>(remoteMethod.Body, true));
        }