예제 #1
0
        internal void Send(JsonRPCFuture future, out Task <IPremiseObject> task)
        {
            _futures[future.id] = future;

            task = Task.Run(
                () =>
            {
                string strMessage = JsonConvert.SerializeObject(future);
                base.Send(strMessage);

                dynamic result;
                try
                {
                    result = future.Await();
                }
                catch (Exception ex)
                {
                    OnError(ex);
                    return(null);
                }

                var premiseObject = new PremiseObject(this, (string)result);
                return((IPremiseObject)premiseObject);
            });
        }
예제 #2
0
        internal void Send(JsonRPCFuture future, out Task <IPremiseObjectCollection> task)
        {
            _futures[future.id] = future;

            task = Task.Run(
                () =>
            {
                string strMessage = JsonConvert.SerializeObject(future);
                base.Send(strMessage);

                JArray result;
                try
                {
                    result = future.Await() as JArray;
                }
                catch (Exception ex)
                {
                    OnError(ex);
                    return(null);
                }
                var premiseObjects = new List <IPremiseObject>();
                if (result == null)
                {
                    return(null);
                }
                foreach (var item in result)
                {
                    var premiseObject = new PremiseObject(this, (string)item);
                    premiseObjects.Add(premiseObject);
                }
                var collection = (IPremiseObjectCollection)premiseObjects;
                return(collection);
            });
        }
예제 #3
0
        internal void Send <T>(JsonRPCFuture future, out Task <T> task)
        {
            _futures[future.id] = future;

            task = Task.Run(
                () =>
            {
                string strMessage = JsonConvert.SerializeObject(future);
                base.Send(strMessage);

                dynamic result = future.Await();
                return((T)result);
            });
        }
예제 #4
0
        internal void Send(JsonRPCFuture future, out Task task)
        {
            _futures[future.id] = future;

            task = Task.Run(
                () =>
            {
                string strMessage = JsonConvert.SerializeObject(future);
                base.Send(strMessage);
                try
                {
                    future.Await();
                }
                catch (Exception ex)
                {
                    OnError(ex);
                }
            });
        }