private static void UnmarshallResult(JsonUnmarshallerContext context,QueryResponse response)
{
int originalDepth = context.CurrentDepth;
int targetDepth = originalDepth + 1;
while (context.Read())
{
if (context.TestExpression("Items", targetDepth))
{
context.Read();
response.Items = new List<Dictionary<string,AttributeValue>>();
DictionaryUnmarshaller<string, AttributeValue, StringUnmarshaller, AttributeValueUnmarshaller> unmarshaller = new DictionaryUnmarshaller<string, AttributeValue, StringUnmarshaller, AttributeValueUnmarshaller>(StringUnmarshaller.GetInstance(),AttributeValueUnmarshaller.GetInstance());
while (context.Read())
{
JsonToken token = context.CurrentTokenType;
if (token == JsonToken.ArrayStart)
{
continue;
}
if (token == JsonToken.ArrayEnd)
{
break;
}
response.Items.Add(unmarshaller.Unmarshall(context));
}
continue;
}
if (context.TestExpression("Count", targetDepth))
{
context.Read();
response.Count = IntUnmarshaller.GetInstance().Unmarshall(context);
continue;
}
if (context.TestExpression("LastEvaluatedKey", targetDepth))
{
context.Read();
response.LastEvaluatedKey = new Dictionary<String,AttributeValue>();
KeyValueUnmarshaller<string, AttributeValue, StringUnmarshaller, AttributeValueUnmarshaller> unmarshaller = new KeyValueUnmarshaller<string, AttributeValue, StringUnmarshaller, AttributeValueUnmarshaller>(StringUnmarshaller.GetInstance(), AttributeValueUnmarshaller.GetInstance());
while (context.Read())
{
JsonToken token = context.CurrentTokenType;
if (token == JsonToken.ArrayStart || token == JsonToken.ObjectStart)
{
continue;
}
if (token == JsonToken.ArrayEnd || token == JsonToken.ObjectEnd)
{
break;
}
KeyValuePair<string, AttributeValue> kvp = unmarshaller.Unmarshall(context);
response.LastEvaluatedKey.Add(kvp.Key, kvp.Value);
}
continue;
}
if (context.TestExpression("ConsumedCapacity", targetDepth))
{
context.Read();
response.ConsumedCapacity = ConsumedCapacityUnmarshaller.GetInstance().Unmarshall(context);
continue;
}
if (context.CurrentDepth <= originalDepth)
{
return;
}
}
return;
}