Ejemplo n.º 1
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            ListLocalDisksResponse response = new ListLocalDisksResponse();

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

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Disks", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <Disk, DiskUnmarshaller>(DiskUnmarshaller.Instance);
                    response.Disks = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("GatewayARN", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.GatewayARN = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
Ejemplo n.º 2
0
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            ListLocalDisksResponse response = new ListLocalDisksResponse();

            context.Read();
            response.ListLocalDisksResult = ListLocalDisksResultUnmarshaller.GetInstance().Unmarshall(context);

            return(response);
        }
Ejemplo n.º 3
0
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            ListLocalDisksResponse response = new ListLocalDisksResponse();

            context.Read();

            UnmarshallResult(context, response);
            return(response);
        }
Ejemplo n.º 4
0
        private static void UnmarshallResult(JsonUnmarshallerContext context, ListLocalDisksResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

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

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

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

            return;
        }
Ejemplo n.º 5
0
        public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonStorageGatewayConfig config = new AmazonStorageGatewayConfig();

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

            ListLocalDisksResponse resp = new ListLocalDisksResponse();
            ListLocalDisksRequest  req  = new ListLocalDisksRequest
            {
            };

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

            foreach (var obj in resp.Disks)
            {
                AddObject(obj);
            }
        }