Пример #1
0
        public Key Unmarshall(JsonUnmarshallerContext context)
        {
            Key key = new Key();

            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            while (context.Read())
            {
                if ((context.IsKey) && (context.CurrentDepth == targetDepth))
                {
                    context.Read();
                    context.Read();

                    if (context.TestExpression("HashKeyElement", targetDepth))
                    {
                        key.HashKeyElement = AttributeValueUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }

                    if (context.TestExpression("RangeKeyElement", targetDepth))
                    {
                        key.RangeKeyElement = AttributeValueUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth <= originalDepth)
                {
                    return(key);
                }
            }


            return(key);
        }
        public GetItemResult Unmarshall(JsonUnmarshallerContext context)
        {
            GetItemResult getItemResult = new GetItemResult();

            getItemResult.Item = 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("Item", targetDepth))
                    {
                        getItemResult.Item = 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);
                                getItemResult.Item.Add(kvp.Key, kvp.Value);
                            }
                            else if (context.IsEndElement)
                            {
                                break;
                            }
                        }
                        continue;
                    }

                    if (context.TestExpression("ConsumedCapacityUnits", targetDepth))
                    {
                        getItemResult.ConsumedCapacityUnits = DoubleUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth <= originalDepth)
                {
                    return(getItemResult);
                }
            }


            return(getItemResult);
        }
Пример #3
0
        public ScanResult Unmarshall(JsonUnmarshallerContext context)
        {
            ScanResult scanResult = new ScanResult();

            scanResult.Items = 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("Items", targetDepth))
                    {
                        scanResult.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())
                        {
                            if ((context.IsArrayElement) && (context.CurrentDepth == targetDepth))
                            {
                                scanResult.Items.Add(unmarshaller.Unmarshall(context));
                            }
                            else if (context.IsEndArray)
                            {
                                break;
                            }
                        }
                        continue;
                    }

                    if (context.TestExpression("Count", targetDepth))
                    {
                        scanResult.Count = IntUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }

                    if (context.TestExpression("ScannedCount", targetDepth))
                    {
                        scanResult.ScannedCount = IntUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }

                    if (context.TestExpression("LastEvaluatedKey", targetDepth))
                    {
                        scanResult.LastEvaluatedKey = KeyUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }

                    if (context.TestExpression("ConsumedCapacityUnits", targetDepth))
                    {
                        scanResult.ConsumedCapacityUnits = DoubleUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth <= originalDepth)
                {
                    return(scanResult);
                }
            }


            return(scanResult);
        }
        public BatchResponse Unmarshall(JsonUnmarshallerContext context)
        {
            BatchResponse batchResponse = new BatchResponse();

            batchResponse.Items = 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("Items", targetDepth))
                    {
                        batchResponse.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())
                        {
                            if ((context.IsArrayElement) && (context.CurrentDepth == targetDepth))
                            {
                                batchResponse.Items.Add(unmarshaller.Unmarshall(context));
                            }
                            else if (context.IsEndArray)
                            {
                                break;
                            }
                        }
                        continue;
                    }

                    if (context.TestExpression("ConsumedCapacityUnits", targetDepth))
                    {
                        batchResponse.ConsumedCapacityUnits = DoubleUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth <= originalDepth)
                {
                    return(batchResponse);
                }
            }


            return(batchResponse);
        }