Esempio n. 1
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            ListJobsByStatusResponse response = new ListJobsByStatusResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Jobs", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <Job, JobUnmarshaller>(JobUnmarshaller.Instance);
                    response.Jobs = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("NextPageToken", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.NextPageToken = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            ListJobsByStatusResponse response = new ListJobsByStatusResponse();

            context.Read();

            UnmarshallResult(context, response);
            return(response);
        }
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            ListJobsByStatusResponse response = new ListJobsByStatusResponse();

            context.Read();

            response.ListJobsByStatusResult = ListJobsByStatusResultUnmarshaller.GetInstance().Unmarshall(context);

            return(response);
        }
        private static void UnmarshallResult(JsonUnmarshallerContext context, ListJobsByStatusResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            while (context.Read())
            {
                if (context.TestExpression("Jobs", targetDepth))
                {
                    context.Read();

                    if (context.CurrentTokenType == JsonToken.Null)
                    {
                        response.Jobs = null;
                        continue;
                    }
                    response.Jobs = new List <Job>();
                    JobUnmarshaller unmarshaller = JobUnmarshaller.GetInstance();
                    while (context.Read())
                    {
                        JsonToken token = context.CurrentTokenType;
                        if (token == JsonToken.ArrayStart)
                        {
                            continue;
                        }
                        if (token == JsonToken.ArrayEnd)
                        {
                            break;
                        }
                        response.Jobs.Add(unmarshaller.Unmarshall(context));
                    }
                    continue;
                }

                if (context.TestExpression("NextPageToken", targetDepth))
                {
                    context.Read();
                    response.NextPageToken = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.CurrentDepth <= originalDepth)
                {
                    return;
                }
            }

            return;
        }