public ItemCollectionMetrics Unmarshall(JsonUnmarshallerContext context) { if (context.CurrentTokenType == JsonToken.Null) { return(null); } ItemCollectionMetrics itemCollectionMetrics = new ItemCollectionMetrics(); int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; while (context.Read()) { if (context.TestExpression("ItemCollectionKey", targetDepth)) { context.Read(); itemCollectionMetrics.ItemCollectionKey = 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); itemCollectionMetrics.ItemCollectionKey.Add(kvp.Key, kvp.Value); } continue; } if (context.TestExpression("SizeEstimateRangeGB", targetDepth)) { context.Read(); itemCollectionMetrics.SizeEstimateRangeGB = new List <Double>(); DoubleUnmarshaller unmarshaller = DoubleUnmarshaller.GetInstance(); while (context.Read()) { JsonToken token = context.CurrentTokenType; if (token == JsonToken.ArrayStart) { continue; } if (token == JsonToken.ArrayEnd) { break; } itemCollectionMetrics.SizeEstimateRangeGB.Add(unmarshaller.Unmarshall(context)); } continue; } if (context.CurrentDepth <= originalDepth) { return(itemCollectionMetrics); } } return(itemCollectionMetrics); }
public ItemCollectionMetrics Unmarshall(JsonUnmarshallerContext context) { ItemCollectionMetrics itemCollectionMetrics = new ItemCollectionMetrics(); itemCollectionMetrics.ItemCollectionKey = null; itemCollectionMetrics.SizeEstimateRangeGB = 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("ItemCollectionKey", targetDepth)) { itemCollectionMetrics.ItemCollectionKey = new Dictionary <String, AttributeValue>(); KeyValueUnmarshaller <string, AttributeValue, StringUnmarshaller, AttributeValueUnmarshaller> unmarshaller = new KeyValueUnmarshaller <string, AttributeValue, StringUnmarshaller, AttributeValueUnmarshaller>(StringUnmarshaller.GetInstance(), AttributeValueUnmarshaller.GetInstance()); while (context.Read()) { if (((context.IsStartArray || context.IsStartElement || context.IsLeafValue) && (context.CurrentDepth == targetDepth)) || ((context.IsKey) && (context.CurrentDepth == targetDepth + 1))) { KeyValuePair <string, AttributeValue> kvp = unmarshaller.Unmarshall(context); itemCollectionMetrics.ItemCollectionKey.Add(kvp.Key, kvp.Value); } else if (context.IsEndElement) { break; } } continue; } if (context.TestExpression("SizeEstimateRangeGB", targetDepth)) { itemCollectionMetrics.SizeEstimateRangeGB = new List <Double>(); DoubleUnmarshaller unmarshaller = DoubleUnmarshaller.GetInstance(); while (context.Read()) { if ((context.IsArrayElement) && (context.CurrentDepth == targetDepth)) { itemCollectionMetrics.SizeEstimateRangeGB.Add(unmarshaller.Unmarshall(context)); } else if (context.IsEndArray) { break; } } continue; } } else if (context.IsEndElement && context.CurrentDepth <= originalDepth) { return(itemCollectionMetrics); } } return(itemCollectionMetrics); }