Beispiel #1
0
        public ItemCollectionMetrics Unmarshall(JsonUnmarshallerContext context)
        {
            context.Read();
            if (context.CurrentTokenType == JsonToken.Null)
            {
                return(null);
            }
            ItemCollectionMetrics itemCollectionMetrics = new ItemCollectionMetrics();


            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("ItemCollectionKey", targetDepth))
                {
                    var unmarshaller = new DictionaryUnmarshaller <String, AttributeValue, StringUnmarshaller, AttributeValueUnmarshaller>(
                        StringUnmarshaller.GetInstance(), AttributeValueUnmarshaller.GetInstance());
                    itemCollectionMetrics.ItemCollectionKey = unmarshaller.Unmarshall(context);

                    continue;
                }

                if (context.TestExpression("SizeEstimateRangeGB", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <Double, DoubleUnmarshaller>(
                        DoubleUnmarshaller.GetInstance());
                    itemCollectionMetrics.SizeEstimateRangeGB = unmarshaller.Unmarshall(context);

                    continue;
                }
            }

            return(itemCollectionMetrics);
        }
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            PutItemResponse response = new PutItemResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Attributes", targetDepth))
                {
                    var unmarshaller = new DictionaryUnmarshaller <String, AttributeValue, StringUnmarshaller, AttributeValueUnmarshaller>(
                        StringUnmarshaller.GetInstance(), AttributeValueUnmarshaller.GetInstance());
                    response.Attributes = unmarshaller.Unmarshall(context);

                    continue;
                }

                if (context.TestExpression("ConsumedCapacity", targetDepth))
                {
                    response.ConsumedCapacity = ConsumedCapacityUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("ItemCollectionMetrics", targetDepth))
                {
                    response.ItemCollectionMetrics = ItemCollectionMetricsUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
        public PutRequest Unmarshall(JsonUnmarshallerContext context)
        {
            context.Read();
            if (context.CurrentTokenType == JsonToken.Null)
            {
                return(null);
            }
            PutRequest putRequest = new PutRequest();


            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Item", targetDepth))
                {
                    var unmarshaller = new DictionaryUnmarshaller <String, AttributeValue, StringUnmarshaller, AttributeValueUnmarshaller>(
                        StringUnmarshaller.GetInstance(), AttributeValueUnmarshaller.GetInstance());
                    putRequest.Item = unmarshaller.Unmarshall(context);

                    continue;
                }
            }

            return(putRequest);
        }
Beispiel #4
0
 public static AttributeValueUnmarshaller GetInstance()
 {
     if (instance == null)
     {
         instance = new AttributeValueUnmarshaller();
     }
     return(instance);
 }
Beispiel #5
0
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            ScanResponse response = new ScanResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Items", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <Dictionary <string, AttributeValue>, DictionaryUnmarshaller <string, AttributeValue, StringUnmarshaller, AttributeValueUnmarshaller> >(
                        new DictionaryUnmarshaller <string, AttributeValue, StringUnmarshaller, AttributeValueUnmarshaller>(StringUnmarshaller.GetInstance(), AttributeValueUnmarshaller.GetInstance()));
                    response.Items = unmarshaller.Unmarshall(context);

                    continue;
                }

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

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

                if (context.TestExpression("LastEvaluatedKey", targetDepth))
                {
                    var unmarshaller = new DictionaryUnmarshaller <String, AttributeValue, StringUnmarshaller, AttributeValueUnmarshaller>(
                        StringUnmarshaller.GetInstance(), AttributeValueUnmarshaller.GetInstance());
                    response.LastEvaluatedKey = unmarshaller.Unmarshall(context);

                    continue;
                }

                if (context.TestExpression("ConsumedCapacity", targetDepth))
                {
                    response.ConsumedCapacity = ConsumedCapacityUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
        private static void UnmarshallResult(JsonUnmarshallerContext context, DeleteItemResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            while (context.Read())
            {
                if (context.TestExpression("Attributes", targetDepth))
                {
                    context.Read();
                    response.Attributes = new Dictionary <String, AttributeValue>();
                    if (context.CurrentTokenType == JsonToken.Null)
                    {
                        continue;
                    }
                    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.Attributes.Add(kvp.Key, kvp.Value);
                    }
                    continue;
                }

                if (context.TestExpression("ConsumedCapacity", targetDepth))
                {
                    context.Read();
                    response.ConsumedCapacity = ConsumedCapacityUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("ItemCollectionMetrics", targetDepth))
                {
                    context.Read();
                    response.ItemCollectionMetrics = ItemCollectionMetricsUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.CurrentDepth <= originalDepth)
                {
                    return;
                }
            }

            return;
        }
        private static void UnmarshallResult(JsonUnmarshallerContext context, BatchGetItemResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            while (context.Read())
            {
                if (context.TestExpression("Responses", targetDepth))
                {
                    context.Read();
                    response.Responses = new Dictionary <String, List <Dictionary <string, AttributeValue> > >();
                    if (context.CurrentTokenType == JsonToken.Null)
                    {
                        continue;
                    }
                    KeyValueUnmarshaller <string, List <Dictionary <string, AttributeValue> >, StringUnmarshaller, ListUnmarshaller <Dictionary <string, AttributeValue>, DictionaryUnmarshaller <string, AttributeValue, StringUnmarshaller, AttributeValueUnmarshaller> > > unmarshaller = new KeyValueUnmarshaller <string, List <Dictionary <string, AttributeValue> >, StringUnmarshaller, ListUnmarshaller <Dictionary <string, AttributeValue>, DictionaryUnmarshaller <string, AttributeValue, StringUnmarshaller, AttributeValueUnmarshaller> > >(StringUnmarshaller.GetInstance(), new ListUnmarshaller <Dictionary <string, AttributeValue>, DictionaryUnmarshaller <string, AttributeValue, StringUnmarshaller, AttributeValueUnmarshaller> >(new DictionaryUnmarshaller <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, List <Dictionary <string, AttributeValue> > > kvp = unmarshaller.Unmarshall(context);
                        response.Responses.Add(kvp.Key, kvp.Value);
                    }
                    continue;
                }

                if (context.TestExpression("UnprocessedKeys", targetDepth))
                {
                    context.Read();
                    response.UnprocessedKeys = new Dictionary <String, KeysAndAttributes>();
                    if (context.CurrentTokenType == JsonToken.Null)
                    {
                        continue;
                    }
                    KeyValueUnmarshaller <string, KeysAndAttributes, StringUnmarshaller, KeysAndAttributesUnmarshaller> unmarshaller = new KeyValueUnmarshaller <string, KeysAndAttributes, StringUnmarshaller, KeysAndAttributesUnmarshaller>(StringUnmarshaller.GetInstance(), KeysAndAttributesUnmarshaller.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, KeysAndAttributes> kvp = unmarshaller.Unmarshall(context);
                        response.UnprocessedKeys.Add(kvp.Key, kvp.Value);
                    }
                    continue;
                }

                if (context.TestExpression("ConsumedCapacity", targetDepth))
                {
                    context.Read();
                    response.ConsumedCapacity = new List <ConsumedCapacity>();
                    if (context.CurrentTokenType == JsonToken.Null)
                    {
                        continue;
                    }
                    ConsumedCapacityUnmarshaller unmarshaller = ConsumedCapacityUnmarshaller.GetInstance();
                    while (context.Read())
                    {
                        JsonToken token = context.CurrentTokenType;
                        if (token == JsonToken.ArrayStart)
                        {
                            continue;
                        }
                        if (token == JsonToken.ArrayEnd)
                        {
                            break;
                        }
                        response.ConsumedCapacity.Add(unmarshaller.Unmarshall(context));
                    }
                    continue;
                }

                if (context.CurrentDepth <= originalDepth)
                {
                    return;
                }
            }

            return;
        }
Beispiel #8
0
        public DeleteRequest Unmarshall(JsonUnmarshallerContext context)
        {
            if (context.CurrentTokenType == JsonToken.Null)
            {
                return(null);
            }

            DeleteRequest deleteRequest = new DeleteRequest();



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

            while (context.Read())
            {
                if (context.TestExpression("Key", targetDepth))
                {
                    context.Read();
                    deleteRequest.Key = new Dictionary <String, AttributeValue>();
                    if (context.CurrentTokenType == JsonToken.Null)
                    {
                        continue;
                    }
                    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);
                        deleteRequest.Key.Add(kvp.Key, kvp.Value);
                    }
                    continue;
                }

                if (context.CurrentDepth <= originalDepth)
                {
                    return(deleteRequest);
                }
            }


            return(deleteRequest);
        }
        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);
        }
Beispiel #10
0
        public KeysAndAttributes Unmarshall(JsonUnmarshallerContext context)
        {
            context.Read();
            if (context.CurrentTokenType == JsonToken.Null)
            {
                return(null);
            }
            KeysAndAttributes keysAndAttributes = new KeysAndAttributes();


            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Keys", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <Dictionary <string, AttributeValue>, DictionaryUnmarshaller <string, AttributeValue, StringUnmarshaller, AttributeValueUnmarshaller> >(
                        new DictionaryUnmarshaller <string, AttributeValue, StringUnmarshaller, AttributeValueUnmarshaller>(StringUnmarshaller.GetInstance(), AttributeValueUnmarshaller.GetInstance()));
                    keysAndAttributes.Keys = unmarshaller.Unmarshall(context);

                    continue;
                }

                if (context.TestExpression("AttributesToGet", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <String, StringUnmarshaller>(
                        StringUnmarshaller.GetInstance());
                    keysAndAttributes.AttributesToGet = unmarshaller.Unmarshall(context);

                    continue;
                }

                if (context.TestExpression("ConsistentRead", targetDepth))
                {
                    keysAndAttributes.ConsistentRead = BoolUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }
            }

            return(keysAndAttributes);
        }
        public KeysAndAttributes Unmarshall(JsonUnmarshallerContext context)
        {
            KeysAndAttributes keysAndAttributes = new KeysAndAttributes();

            keysAndAttributes.Keys            = null;
            keysAndAttributes.AttributesToGet = 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("Keys", targetDepth))
                    {
                        keysAndAttributes.Keys = 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))
                            {
                                keysAndAttributes.Keys.Add(unmarshaller.Unmarshall(context));
                            }
                            else if (context.IsEndArray)
                            {
                                break;
                            }
                        }
                        continue;
                    }

                    if (context.TestExpression("AttributesToGet", targetDepth))
                    {
                        keysAndAttributes.AttributesToGet = new List <String>();
                        StringUnmarshaller unmarshaller = StringUnmarshaller.GetInstance();
                        while (context.Read())
                        {
                            if ((context.IsArrayElement) && (context.CurrentDepth == targetDepth))
                            {
                                keysAndAttributes.AttributesToGet.Add(unmarshaller.Unmarshall(context));
                            }
                            else if (context.IsEndArray)
                            {
                                break;
                            }
                        }
                        continue;
                    }

                    if (context.TestExpression("ConsistentRead", targetDepth))
                    {
                        keysAndAttributes.ConsistentRead = BoolUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth <= originalDepth)
                {
                    return(keysAndAttributes);
                }
            }


            return(keysAndAttributes);
        }
        public QueryResult Unmarshall(JsonUnmarshallerContext context)
        {
            QueryResult queryResult = new QueryResult();

            queryResult.Items            = null;
            queryResult.LastEvaluatedKey = 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))
                    {
                        queryResult.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))
                            {
                                queryResult.Items.Add(unmarshaller.Unmarshall(context));
                            }
                            else if (context.IsEndArray)
                            {
                                break;
                            }
                        }
                        continue;
                    }

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

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

                    if (context.TestExpression("ConsumedCapacity", targetDepth))
                    {
                        queryResult.ConsumedCapacity = ConsumedCapacityUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth <= originalDepth)
                {
                    return(queryResult);
                }
            }


            return(queryResult);
        }
Beispiel #13
0
        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);
        }
Beispiel #14
0
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            BatchGetItemResponse response = new BatchGetItemResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Responses", targetDepth))
                {
                    var unmarshaller = new DictionaryUnmarshaller <String, List <Dictionary <string, AttributeValue> >, StringUnmarshaller, ListUnmarshaller <Dictionary <string, AttributeValue>, DictionaryUnmarshaller <string, AttributeValue, StringUnmarshaller, AttributeValueUnmarshaller> > >(
                        StringUnmarshaller.GetInstance(), new ListUnmarshaller <Dictionary <string, AttributeValue>, DictionaryUnmarshaller <string, AttributeValue, StringUnmarshaller, AttributeValueUnmarshaller> >(new DictionaryUnmarshaller <string, AttributeValue, StringUnmarshaller, AttributeValueUnmarshaller>(StringUnmarshaller.GetInstance(), AttributeValueUnmarshaller.GetInstance())));
                    response.Responses = unmarshaller.Unmarshall(context);

                    continue;
                }

                if (context.TestExpression("UnprocessedKeys", targetDepth))
                {
                    var unmarshaller = new DictionaryUnmarshaller <String, KeysAndAttributes, StringUnmarshaller, KeysAndAttributesUnmarshaller>(
                        StringUnmarshaller.GetInstance(), KeysAndAttributesUnmarshaller.GetInstance());
                    response.UnprocessedKeys = unmarshaller.Unmarshall(context);

                    continue;
                }

                if (context.TestExpression("ConsumedCapacity", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <ConsumedCapacity, ConsumedCapacityUnmarshaller>(
                        ConsumedCapacityUnmarshaller.GetInstance());
                    response.ConsumedCapacity = unmarshaller.Unmarshall(context);

                    continue;
                }
            }

            return(response);
        }
Beispiel #15
0
        public KeysAndAttributes Unmarshall(JsonUnmarshallerContext context)
        {
            if (context.CurrentTokenType == JsonToken.Null)
            {
                return(null);
            }

            KeysAndAttributes keysAndAttributes = new KeysAndAttributes();



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

            while (context.Read())
            {
                if (context.TestExpression("Keys", targetDepth))
                {
                    context.Read();
                    keysAndAttributes.Keys = 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;
                        }
                        keysAndAttributes.Keys.Add(unmarshaller.Unmarshall(context));
                    }
                    continue;
                }

                if (context.TestExpression("AttributesToGet", targetDepth))
                {
                    context.Read();
                    keysAndAttributes.AttributesToGet = new List <String>();
                    StringUnmarshaller unmarshaller = StringUnmarshaller.GetInstance();
                    while (context.Read())
                    {
                        JsonToken token = context.CurrentTokenType;
                        if (token == JsonToken.ArrayStart)
                        {
                            continue;
                        }
                        if (token == JsonToken.ArrayEnd)
                        {
                            break;
                        }
                        keysAndAttributes.AttributesToGet.Add(unmarshaller.Unmarshall(context));
                    }
                    continue;
                }

                if (context.TestExpression("ConsistentRead", targetDepth))
                {
                    context.Read();
                    keysAndAttributes.ConsistentRead = BoolUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.CurrentDepth <= originalDepth)
                {
                    return(keysAndAttributes);
                }
            }


            return(keysAndAttributes);
        }
        public PutItemResult Unmarshall(JsonUnmarshallerContext context)
        {
            PutItemResult putItemResult = new PutItemResult();

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

                    if (context.TestExpression("ConsumedCapacity", targetDepth))
                    {
                        putItemResult.ConsumedCapacity = ConsumedCapacityUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }

                    if (context.TestExpression("ItemCollectionMetrics", targetDepth))
                    {
                        putItemResult.ItemCollectionMetrics = ItemCollectionMetricsUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth <= originalDepth)
                {
                    return(putItemResult);
                }
            }


            return(putItemResult);
        }
Beispiel #17
0
        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;
        }
Beispiel #18
0
        public BatchGetItemResult Unmarshall(JsonUnmarshallerContext context)
        {
            BatchGetItemResult batchGetItemResult = new BatchGetItemResult();

            batchGetItemResult.Responses        = null;
            batchGetItemResult.UnprocessedKeys  = null;
            batchGetItemResult.ConsumedCapacity = 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("Responses", targetDepth))
                    {
                        batchGetItemResult.Responses = new Dictionary <String, List <Dictionary <string, AttributeValue> > >();
                        KeyValueUnmarshaller <string, List <Dictionary <string, AttributeValue> >, StringUnmarshaller, ListUnmarshaller <Dictionary <string, AttributeValue>, DictionaryUnmarshaller <string, AttributeValue, StringUnmarshaller, AttributeValueUnmarshaller> > > unmarshaller = new KeyValueUnmarshaller <string, List <Dictionary <string, AttributeValue> >, StringUnmarshaller, ListUnmarshaller <Dictionary <string, AttributeValue>, DictionaryUnmarshaller <string, AttributeValue, StringUnmarshaller, AttributeValueUnmarshaller> > >(StringUnmarshaller.GetInstance(), new ListUnmarshaller <Dictionary <string, AttributeValue>, DictionaryUnmarshaller <string, AttributeValue, StringUnmarshaller, AttributeValueUnmarshaller> >(new DictionaryUnmarshaller <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, List <Dictionary <string, AttributeValue> > > kvp = unmarshaller.Unmarshall(context);
                                batchGetItemResult.Responses.Add(kvp.Key, kvp.Value);
                            }
                            else if (context.IsEndElement)
                            {
                                break;
                            }
                        }
                        continue;
                    }

                    if (context.TestExpression("UnprocessedKeys", targetDepth))
                    {
                        batchGetItemResult.UnprocessedKeys = new Dictionary <String, KeysAndAttributes>();
                        KeyValueUnmarshaller <string, KeysAndAttributes, StringUnmarshaller, KeysAndAttributesUnmarshaller> unmarshaller = new KeyValueUnmarshaller <string, KeysAndAttributes, StringUnmarshaller, KeysAndAttributesUnmarshaller>(StringUnmarshaller.GetInstance(), KeysAndAttributesUnmarshaller.GetInstance());
                        while (context.Read())
                        {
                            if (((context.IsStartArray || context.IsStartElement || context.IsLeafValue) && (context.CurrentDepth == targetDepth)) ||
                                ((context.IsKey) && (context.CurrentDepth == targetDepth + 1)))
                            {
                                KeyValuePair <string, KeysAndAttributes> kvp = unmarshaller.Unmarshall(context);
                                batchGetItemResult.UnprocessedKeys.Add(kvp.Key, kvp.Value);
                            }
                            else if (context.IsEndElement)
                            {
                                break;
                            }
                        }
                        continue;
                    }

                    if (context.TestExpression("ConsumedCapacity", targetDepth))
                    {
                        batchGetItemResult.ConsumedCapacity = new List <ConsumedCapacity>();
                        ConsumedCapacityUnmarshaller unmarshaller = ConsumedCapacityUnmarshaller.GetInstance();
                        while (context.Read())
                        {
                            if ((context.IsArrayElement) && (context.CurrentDepth == targetDepth))
                            {
                                batchGetItemResult.ConsumedCapacity.Add(unmarshaller.Unmarshall(context));
                            }
                            else if (context.IsEndArray)
                            {
                                break;
                            }
                        }
                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth <= originalDepth)
                {
                    return(batchGetItemResult);
                }
            }


            return(batchGetItemResult);
        }
        public DeleteRequest Unmarshall(JsonUnmarshallerContext context)
        {
            DeleteRequest deleteRequest = new DeleteRequest();

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


            return(deleteRequest);
        }