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;
            }
        }
Esempio n. 2
0
        internal RequestMessageBody BuildRequestMessageBody()
        {
            Dictionary<int, ObjectPathInfo> objectPaths = new Dictionary<int, ObjectPathInfo>();
            foreach (var pair in this.m_referencedObjectPaths)
            {
                objectPaths[pair.Key] = pair.Value.ObjectPathInfo;
            }

            List<ActionInfo> actions = new List<ActionInfo>();
            foreach (Action action in this.m_actions)
            {
                actions.Add(action.ActionInfo);
            }

            RequestMessageBody ret = new RequestMessageBody();
            ret.Actions = actions;
            ret.ObjectPaths = objectPaths;

            return ret;
        }