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

            context.Read();

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

            context.Read();

            response.DescribeInterconnectsResult = DescribeInterconnectsResultUnmarshaller.GetInstance().Unmarshall(context);

            return(response);
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            DescribeInterconnectsResponse response = new DescribeInterconnectsResponse();

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

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("interconnects", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <Interconnect, InterconnectUnmarshaller>(InterconnectUnmarshaller.Instance);
                    response.Interconnects = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
Exemplo n.º 4
0
        public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonDirectConnectConfig config = new AmazonDirectConnectConfig();

            config.RegionEndpoint = region;
            ConfigureClient(config);
            AmazonDirectConnectClient client = new AmazonDirectConnectClient(creds, config);

            DescribeInterconnectsResponse resp = new DescribeInterconnectsResponse();
            DescribeInterconnectsRequest  req  = new DescribeInterconnectsRequest
            {
            };

            resp = client.DescribeInterconnects(req);
            CheckError(resp.HttpStatusCode, "200");

            foreach (var obj in resp.Interconnects)
            {
                AddObject(obj);
            }
        }
        private static void UnmarshallResult(JsonUnmarshallerContext context, DescribeInterconnectsResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

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

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

            return;
        }