public static ServiceUnmarshaller GetInstance() { if (instance == null) { instance = new ServiceUnmarshaller(); } return(instance); }
public DescribeServicesResult Unmarshall(JsonUnmarshallerContext context) { DescribeServicesResult describeServicesResult = new DescribeServicesResult(); describeServicesResult.Services = 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("Services", targetDepth)) { describeServicesResult.Services = new List <Service>(); ServiceUnmarshaller unmarshaller = ServiceUnmarshaller.GetInstance(); while (context.Read()) { if ((context.IsArrayElement) && (context.CurrentDepth == targetDepth)) { describeServicesResult.Services.Add(unmarshaller.Unmarshall(context)); } else if (context.IsEndArray) { break; } } continue; } } else if (context.IsEndElement && context.CurrentDepth <= originalDepth) { return(describeServicesResult); } } return(describeServicesResult); }
private static void UnmarshallResult(JsonUnmarshallerContext context, DescribeServicesResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; while (context.Read()) { if (context.TestExpression("services", targetDepth)) { context.Read(); if (context.CurrentTokenType == JsonToken.Null) { response.Services = null; continue; } response.Services = new List <Service>(); ServiceUnmarshaller unmarshaller = ServiceUnmarshaller.GetInstance(); while (context.Read()) { JsonToken token = context.CurrentTokenType; if (token == JsonToken.ArrayStart) { continue; } if (token == JsonToken.ArrayEnd) { break; } response.Services.Add(unmarshaller.Unmarshall(context)); } continue; } if (context.CurrentDepth <= originalDepth) { return; } } return; }
public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { DescribeServicesResponse response = new DescribeServicesResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("services", targetDepth)) { var unmarshaller = new ListUnmarshaller <Service, ServiceUnmarshaller>( ServiceUnmarshaller.GetInstance()); response.Services = unmarshaller.Unmarshall(context); continue; } } return(response); }