Esempio n. 1
0
 // Called via reflection:
 Proxy(FastIpc channel, int objectID, byte domainAddress, Type actualInstanceType)
 {
     Channel            = channel;
     ObjectID           = objectID;
     DomainAddress      = domainAddress;
     m_ActualObjectType = actualInstanceType;
 }
Esempio n. 2
0
        /// <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));
        }
Esempio n. 3
0
 void IProxy.RegisterLocal(FastIpc fastChannel, int?objectID, Action onDisconnect)
 {
     // This is called by FastChannel to connect/register the proxy.
     lock (m_Lock)
     {
         Channel        = fastChannel;
         ObjectID       = objectID;
         DomainAddress  = fastChannel.DomainAddress;
         m_OnDisconnect = onDisconnect;
     }
 }
Esempio n. 4
0
        /// <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));
        }