public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            DescribeCasesResponse response = new DescribeCasesResponse();

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

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("cases", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <CaseDetails, CaseDetailsUnmarshaller>(
                        CaseDetailsUnmarshaller.GetInstance());
                    response.Cases = unmarshaller.Unmarshall(context);

                    continue;
                }

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

            return(response);
        }
 public static CaseDetailsUnmarshaller GetInstance()
 {
     if (instance == null)
     {
         instance = new CaseDetailsUnmarshaller();
     }
     return(instance);
 }
        private static void UnmarshallResult(JsonUnmarshallerContext context, DescribeCasesResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

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

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

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

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

            return;
        }
Esempio n. 4
0
        public DescribeCasesResult Unmarshall(JsonUnmarshallerContext context)
        {
            DescribeCasesResult describeCasesResult = new DescribeCasesResult();

            describeCasesResult.Cases = 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("Cases", targetDepth))
                    {
                        describeCasesResult.Cases = new List <CaseDetails>();
                        CaseDetailsUnmarshaller unmarshaller = CaseDetailsUnmarshaller.GetInstance();
                        while (context.Read())
                        {
                            if ((context.IsArrayElement) && (context.CurrentDepth == targetDepth))
                            {
                                describeCasesResult.Cases.Add(unmarshaller.Unmarshall(context));
                            }
                            else if (context.IsEndArray)
                            {
                                break;
                            }
                        }
                        continue;
                    }

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


            return(describeCasesResult);
        }