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); }); }
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); }); }
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); }); }
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); } }); }