Exemplo n.º 1
0
        public ListJobsResult Unmarshall(JsonUnmarshallerContext context)
        {
            ListJobsResult listJobsResult = new ListJobsResult();

            listJobsResult.JobList = null;

            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            while (context.Read())
            {
                if ((context.IsKey) && (context.CurrentDepth == targetDepth))
                {
                    context.Read();
                    context.Read();

                    if (context.TestExpression("JobList", targetDepth))
                    {
                        listJobsResult.JobList = new List <GlacierJobDescription>();
                        GlacierJobDescriptionUnmarshaller unmarshaller = GlacierJobDescriptionUnmarshaller.GetInstance();
                        while (context.Read())
                        {
                            if ((context.IsArrayElement) && (context.CurrentDepth == targetDepth))
                            {
                                listJobsResult.JobList.Add(unmarshaller.Unmarshall(context));
                            }
                            else if (context.IsEndArray)
                            {
                                break;
                            }
                        }
                        continue;
                    }

                    if (context.TestExpression("Marker", targetDepth))
                    {
                        listJobsResult.Marker = StringUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth <= originalDepth)
                {
                    return(listJobsResult);
                }
            }


            return(listJobsResult);
        }
Exemplo n.º 2
0
        private static void UnmarshallResult(JsonUnmarshallerContext context, ListJobsResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

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

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

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

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

            return;
        }