/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { DescribeTapesResponse response = new DescribeTapesResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("Marker", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Marker = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Tapes", targetDepth)) { var unmarshaller = new ListUnmarshaller <Tape, TapeUnmarshaller>(TapeUnmarshaller.Instance); response.Tapes = unmarshaller.Unmarshall(context); continue; } } return(response); }
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); DescribeTapesResponse resp = new DescribeTapesResponse(); do { DescribeTapesRequest req = new DescribeTapesRequest { Marker = resp.Marker , Limit = maxItems }; resp = client.DescribeTapes(req); CheckError(resp.HttpStatusCode, "200"); foreach (var obj in resp.Tapes) { AddObject(obj); } }while (!string.IsNullOrEmpty(resp.Marker)); }
public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { DescribeTapesResponse response = new DescribeTapesResponse(); context.Read(); UnmarshallResult(context, response); return(response); }
private static void UnmarshallResult(JsonUnmarshallerContext context, DescribeTapesResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; while (context.Read()) { if (context.TestExpression("Tapes", targetDepth)) { context.Read(); response.Tapes = new List <Tape>(); TapeUnmarshaller unmarshaller = TapeUnmarshaller.GetInstance(); while (context.Read()) { JsonToken token = context.CurrentTokenType; if (token == JsonToken.ArrayStart) { continue; } if (token == JsonToken.ArrayEnd) { break; } response.Tapes.Add(unmarshaller.Unmarshall(context)); } continue; } if (context.TestExpression("Marker", targetDepth)) { context.Read(); response.Marker = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.CurrentDepth <= originalDepth) { return; } } return; }