private DatasetUpdates PopulateListUpdates(string datasetName, long lastSyncCount, List<Record> records, string nextToken)
{
ListRecordsRequest request = new ListRecordsRequest();
request.IdentityPoolId = identityPoolId;
request.IdentityId = this.GetCurrentIdentityId();
request.DatasetName = datasetName;
request.LastSyncCount = lastSyncCount;
// mark it large enough to reduce # of requests
request.MaxResults = 1024;
request.NextToken = nextToken;
ListRecordsResponse listRecordsResponse = client.ListRecords(request);
foreach (Amazon.CognitoSync.Model.Record remoteRecord in listRecordsResponse.Records)
{
records.Add(ModelToRecord(remoteRecord));
}
if (listRecordsResponse.NextToken != null)
{
// update last evaluated key
nextToken = listRecordsResponse.NextToken;
PopulateListUpdates(datasetName, lastSyncCount, records, nextToken);
}
DatasetUpdates updates = new DatasetUpdates(
datasetName,
records,
listRecordsResponse.DatasetSyncCount,
listRecordsResponse.SyncSessionToken,
listRecordsResponse.DatasetExists,
listRecordsResponse.DatasetDeletedAfterRequestedSyncCount,
listRecordsResponse.MergedDatasetNames
);
return updates;
}