コード例 #1
0
        public DescribeInstancesResult Unmarshall(JsonUnmarshallerContext context)
        {
            if (context.CurrentTokenType == JsonUnmarshallerContext.TokenType.Null)
            {
                return(null);
            }
            DescribeInstancesResult describeInstancesResult = new DescribeInstancesResult();

            describeInstancesResult.Instances = 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("Instances", targetDepth))
                    {
                        describeInstancesResult.Instances = new List <Instance>();
                        InstanceUnmarshaller unmarshaller = InstanceUnmarshaller.GetInstance();
                        while (context.Read())
                        {
                            if ((context.IsArrayElement) && (context.CurrentDepth == targetDepth))
                            {
                                describeInstancesResult.Instances.Add(unmarshaller.Unmarshall(context));
                            }
                            else if (context.IsEndArray)
                            {
                                break;
                            }
                        }
                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth <= originalDepth)
                {
                    return(describeInstancesResult);
                }
            }


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

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

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Instances", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <Instance, InstanceUnmarshaller>(
                        InstanceUnmarshaller.GetInstance());
                    response.Instances = unmarshaller.Unmarshall(context);

                    continue;
                }
            }

            return(response);
        }
コード例 #3
0
        private static void UnmarshallResult(JsonUnmarshallerContext context, DescribeInstancesResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            while (context.Read())
            {
                if (context.TestExpression("Instances", targetDepth))
                {
                    context.Read();
                    response.Instances = new List <Instance>();
                    InstanceUnmarshaller unmarshaller = InstanceUnmarshaller.GetInstance();
                    while (context.Read())
                    {
                        JsonToken token = context.CurrentTokenType;
                        if (token == JsonToken.ArrayStart)
                        {
                            continue;
                        }
                        if (token == JsonToken.ArrayEnd)
                        {
                            break;
                        }
                        response.Instances.Add(unmarshaller.Unmarshall(context));
                    }
                    continue;
                }

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

            return;
        }