public AttributeValue Unmarshall(JsonUnmarshallerContext context) { AttributeValue attributeValue = new AttributeValue(); attributeValue.SS = null; attributeValue.NS = null; attributeValue.BS = 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("S", targetDepth)) { attributeValue.S = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("N", targetDepth)) { attributeValue.N = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("B", targetDepth)) { attributeValue.B = MemoryStreamUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("SS", targetDepth)) { attributeValue.SS = new List <String>(); StringUnmarshaller unmarshaller = StringUnmarshaller.GetInstance(); while (context.Read()) { if ((context.IsArrayElement) && (context.CurrentDepth == targetDepth)) { attributeValue.SS.Add(unmarshaller.Unmarshall(context)); } else if (context.IsEndArray) { break; } } continue; } if (context.TestExpression("NS", targetDepth)) { attributeValue.NS = new List <String>(); StringUnmarshaller unmarshaller = StringUnmarshaller.GetInstance(); while (context.Read()) { if ((context.IsArrayElement) && (context.CurrentDepth == targetDepth)) { attributeValue.NS.Add(unmarshaller.Unmarshall(context)); } else if (context.IsEndArray) { break; } } continue; } if (context.TestExpression("BS", targetDepth)) { attributeValue.BS = new List <MemoryStream>(); MemoryStreamUnmarshaller unmarshaller = MemoryStreamUnmarshaller.GetInstance(); while (context.Read()) { if ((context.IsArrayElement) && (context.CurrentDepth == targetDepth)) { attributeValue.BS.Add(unmarshaller.Unmarshall(context)); } else if (context.IsEndArray) { break; } } continue; } } else if (context.IsEndElement && context.CurrentDepth <= originalDepth) { return(attributeValue); } } return(attributeValue); }
public AttributeValue Unmarshall(JsonUnmarshallerContext context) { if (context.CurrentTokenType == JsonToken.Null) { return(null); } AttributeValue attributeValue = new AttributeValue(); int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; while (context.Read()) { if (context.TestExpression("S", targetDepth)) { context.Read(); attributeValue.S = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("N", targetDepth)) { context.Read(); attributeValue.N = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("B", targetDepth)) { context.Read(); attributeValue.B = MemoryStreamUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("SS", targetDepth)) { context.Read(); attributeValue.SS = new List <String>(); if (context.CurrentTokenType == JsonToken.Null) { continue; } StringUnmarshaller unmarshaller = StringUnmarshaller.GetInstance(); while (context.Read()) { JsonToken token = context.CurrentTokenType; if (token == JsonToken.ArrayStart) { continue; } if (token == JsonToken.ArrayEnd) { break; } attributeValue.SS.Add(unmarshaller.Unmarshall(context)); } continue; } if (context.TestExpression("NS", targetDepth)) { context.Read(); attributeValue.NS = new List <String>(); if (context.CurrentTokenType == JsonToken.Null) { continue; } StringUnmarshaller unmarshaller = StringUnmarshaller.GetInstance(); while (context.Read()) { JsonToken token = context.CurrentTokenType; if (token == JsonToken.ArrayStart) { continue; } if (token == JsonToken.ArrayEnd) { break; } attributeValue.NS.Add(unmarshaller.Unmarshall(context)); } continue; } if (context.TestExpression("BS", targetDepth)) { context.Read(); attributeValue.BS = new List <MemoryStream>(); if (context.CurrentTokenType == JsonToken.Null) { continue; } MemoryStreamUnmarshaller unmarshaller = MemoryStreamUnmarshaller.GetInstance(); while (context.Read()) { JsonToken token = context.CurrentTokenType; if (token == JsonToken.ArrayStart) { continue; } if (token == JsonToken.ArrayEnd) { break; } attributeValue.BS.Add(unmarshaller.Unmarshall(context)); } continue; } if (context.CurrentDepth <= originalDepth) { return(attributeValue); } } return(attributeValue); }