Returns information about the Scan response and response metadata.
Inheritance: ScanResult
 public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
 {
   ScanResponse response = new ScanResponse();          
   
   context.Read();
   
   UnmarshallResult(context,response);
   return response;
 }
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            ScanResponse response = new ScanResponse();

              context.Read();

              response.ScanResult = ScanResultUnmarshaller.GetInstance().Unmarshall(context);

              return response;
        }
Example #3
0
        /// <summary>
        /// Get all users.
        /// </summary>
        /// <returns>All user entities.</returns>
        public async Task <List <User> > GetAll()
        {
            // Get DynamoDB result.
            Amazon.DynamoDBv2.Model.ScanResponse dbResult = await _dynamoDBClient.ScanAsync(
                new Amazon.DynamoDBv2.Model.ScanRequest()
            {
                TableName = "dotnetcore-react-redux-users",
            }
                );

            return(dbResult.Items.Select((item, idx) => this.ConvertDynamoDBItemToUser(item)).ToList());
        }
       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,ScanResponse 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>>();
               if (context.CurrentTokenType == JsonToken.Null)
               {
                   continue;
               }
                 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("ScannedCount", targetDepth))
             {
               context.Read();
               response.ScannedCount = IntUnmarshaller.GetInstance().Unmarshall(context);
               continue;
             }
 
             if (context.TestExpression("LastEvaluatedKey", targetDepth))
             {
               context.Read();
               response.LastEvaluatedKey = 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.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;
       }