public ListGatewaysResult Unmarshall(JsonUnmarshallerContext context) { ListGatewaysResult listGatewaysResult = new ListGatewaysResult(); listGatewaysResult.Gateways = 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("Gateways", targetDepth)) { listGatewaysResult.Gateways = new List <GatewayInfo>(); GatewayInfoUnmarshaller unmarshaller = GatewayInfoUnmarshaller.GetInstance(); while (context.Read()) { if ((context.IsArrayElement) && (context.CurrentDepth == targetDepth)) { listGatewaysResult.Gateways.Add(unmarshaller.Unmarshall(context)); } else if (context.IsEndArray) { break; } } continue; } if (context.TestExpression("Marker", targetDepth)) { listGatewaysResult.Marker = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } } else if (context.IsEndElement && context.CurrentDepth <= originalDepth) { return(listGatewaysResult); } } return(listGatewaysResult); }
private static void UnmarshallResult(JsonUnmarshallerContext context, ListGatewaysResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; while (context.Read()) { if (context.TestExpression("Gateways", targetDepth)) { context.Read(); response.Gateways = new List <GatewayInfo>(); GatewayInfoUnmarshaller unmarshaller = GatewayInfoUnmarshaller.GetInstance(); while (context.Read()) { JsonToken token = context.CurrentTokenType; if (token == JsonToken.ArrayStart) { continue; } if (token == JsonToken.ArrayEnd) { break; } response.Gateways.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; }