public void AddReferencedObjectPath(ObjectPath objectPath) { if (this.m_referencedObjectPaths.ContainsKey(objectPath.ObjectPathInfo.Id)) { return; } if (!objectPath.IsValid) { throw Utility.CreateInvalidObjectPathException(objectPath); } while (objectPath != null) { if (objectPath.IsWriteOperation) { this.m_flags = this.m_flags | ClientRequestFlags.WriteOperation; } this.m_referencedObjectPaths[objectPath.ObjectPathInfo.Id] = objectPath; if (objectPath.ObjectPathInfo.ObjectPathType == ObjectPathType.Method) { this.AddReferencedObjectPaths(objectPath.ArgumentObjectPaths); } objectPath = objectPath.ParentObjectPath; } }
public void AddAction(Action action) { if (action.IsWriteOperation) { this.m_flags = this.m_flags | ClientRequestFlags.WriteOperation; } this.m_actions.Add(action); }
internal ClientRequest(ClientRequestContext context) { this.m_context = context; this.m_actions = new List<Action>(); this.m_actionResultHandler = new Dictionary<int, IResultHandler>(); this.m_referencedObjectPaths = new Dictionary<int, ObjectPath>(); this.m_flags = ClientRequestFlags.None; this.m_traceInfos = new Dictionary<int, string>(); }
public async Task Sync() { ClientRequest req = this.m_pendingRequest; if (req == null) { return; } // If there are no actions to dispatch, short-circuit without sending an empty request to the server if (!req.HasActions) { return; } this.m_pendingRequest = null; RequestMessageBody msgBody = req.BuildRequestMessageBody(); ClientRequestFlags requestFlags = req.Flags; RequestExecutorRequestMessage requestExecutorRequestMessage = new RequestExecutorRequestMessage(); requestExecutorRequestMessage.Url = Utility.CombineUrl(this.m_url, Constants.ProcessQuery); requestExecutorRequestMessage.Body = Utility.ToJsonString(msgBody); foreach (var pair in this.RequestHeaders) { requestExecutorRequestMessage.Headers[pair.Key] = pair.Value; } req.InvalidatePendingInvalidObjectPaths(); RequestExecutorResponseMessage response = await this.m_requestExecutor.Execute(requestExecutorRequestMessage); JToken json = Utility.ToJsonObject(response.Body); this.m_processingResult = true; try { req.ProcessResponse(json); } finally { this.m_processingResult = false; } }