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); }); }
IPremiseObject IPremiseObject.WrapObjectId(string objectId) { var premiseObject = new PremiseObject(_client, objectId); return(premiseObject); }