示例#1
0
        public DescribeLayersResult Unmarshall(JsonUnmarshallerContext context)
        {
            if (context.CurrentTokenType == JsonUnmarshallerContext.TokenType.Null)
            {
                return(null);
            }
            DescribeLayersResult describeLayersResult = new DescribeLayersResult();

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


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

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

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Layers", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <Layer, LayerUnmarshaller>(
                        LayerUnmarshaller.GetInstance());
                    response.Layers = unmarshaller.Unmarshall(context);

                    continue;
                }
            }

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

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

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

            return;
        }