示例#1
0
        public TResult ExecuteOnRemoteSide <TResult>(RemoteSideIDType remoteSideID, RemoteOperationDescriptor rso)
        {
            ThrowIfNotInitialized();
            TResult ret = (TResult)ExecuteOnRemoteSideInternal(remoteSideID, rso);

            return(ret);
        }
        public RemoteRequest CreateRequest(RemoteOperationDescriptor rso)
        {
            if (rso == null)
            {
                throw new ArgumentNullException("rso");
            }

            RemoteRequest ret = new RemoteRequest();

            ret.ExecuteOnRemoteSideOperation = rso;

            return(ret);
        }
示例#3
0
 public override void ReadXml(XmlReader reader)
 {
     base.ReadXml(reader);
     try
     {
         reader.ReadStartElement("ExecuteOnRemoteSideOperation");
         this.ExecuteOnRemoteSideOperation = (RemoteOperationDescriptor)SerializationHelper.DeserializeFromXml(reader);
         reader.ReadEndElement();
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.ToString());
         throw;
     }
 }
示例#4
0
        protected virtual object ExecuteOnRemoteSideInternal(RemoteSideIDType remoteSideID, RemoteOperationDescriptor rso)
        {
            object ret = null;

            if (remoteSideID == null)
            {
                throw new ArgumentNullException("remoteSideID");
            }

            if (rso == null)
            {
                throw new ArgumentNullException("rso");
            }

            // find appropriate client
            IRemoteSideCommunicationContract contract = null;
            bool lockTaken = false;

            try
            {
                syncRoot.Enter(ref lockTaken);
                communicationContractsByRemoteSideIDDict.TryGetValue(remoteSideID, out contract);
            }
            finally
            {
                if (lockTaken)
                {
                    syncRoot.Exit();
                }
            }

            if (contract != null)
            {
                RemoteRequest req = remoteOperationHandler.CreateRequest(rso);
                req.RemoteID = remoteSideID;

                RemoteResponse resp = null;

                try
                {
                    RequestToRemoteSideStarted(remoteSideID, rso);

                    resp = contract.ExecuteRequest(req);
                }
                finally
                {
                    RequestToRemoteSideFinished(remoteSideID, rso);
                }
                ret = remoteOperationHandler.HandleResponse(resp);
            }
            else
            {
                throw new InvalidOperationException(String.Format("Unknown remote side id: {0}", remoteSideID));
            }

            return(ret);
        }
示例#5
0
 protected virtual void RequestToRemoteSideFinished(RemoteSideIDType remoteSideID, RemoteOperationDescriptor rso)
 {
 }
示例#6
0
 public void ExecuteOnRemoteSide(RemoteSideIDType remoteSideID, RemoteOperationDescriptor rso)
 {
     ThrowIfNotInitialized();
     ExecuteOnRemoteSideInternal(remoteSideID, rso);
 }