AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.
//open or create dataset Dataset dataset = cognitoSyncManger.OpenOrCreateDataset("new dataset"); // synchronize. It pulls down latest changes from remote storage // and push local changes to remote storage dataset.Synchronize(); // reads value String highScore = dataset.Get("high_score"); String name = dataset.Get("name"); // sets value dataset.Put("high_score", "90"); dataset.Put("name", "John"); // push changes to remote if needed dataset.Synchronize();
public class Dataset IDisposable
The Dataset type exposes the following members
Gets the Key/Value representation of all records of this dataset. Datasets marked as deleted records are excluded.
Retrieves the associated Amazon.CognitoSync.SyncManager.DatasetMetadata from local storage.
Retrieves all raw records, including those marked as deleted, from local storage.
Gets the total size in bytes of this dataset. Records that are marked as deleted don't contribute to the total size. The size is calculated as sum of UTF-8 string length of key and value for all the records
Clears all the delegates
Delete this Amazon.CognitoSync.SyncManager.Dataset. You cannot do any more operations on this dataset.
Releases the resources consumed by this object
Gets the size of a record with the given key. If the key is deleted, -1 will be returned. The size is calculated as sum of UTF-8 string length of record key and value
Retrieves the status of a record.
Puts a Amazon.CognitoSync.SyncManager.Record with the given key and value into the Dataset. If a Amazon.CognitoSync.SyncManager.Record with the same key exists, its value will be overwritten. If a Amazon.CognitoSync.SyncManager.Record is marked as deleted previously, then it will be resurrected with new value while the sync count continues with previous value. No matter whether the value changes or not, the record is considered as updated, and it will be written to Cognito Sync service on next synchronize operation. If value is null, a ArgumentNullException will be thrown.
Populates a dataset with a dictionary of key/value pairs
Saves resolved conflicting Amazon.CognitoSync.SyncManager.Record into local storage. This is used inside Amazon.CognitoSync.SyncManager.Dataset.SyncConflictDelegate after you resolve all conflicts.
Synchronize Amazon.CognitoSync.SyncManager.Dataset between local storage and remote storage.
Attempt to synchronize Amazon.CognitoSync.SyncManager.Dataset when connectivity is available. If the connectivity is available right away, it behaves the same as Amazon.CognitoSync.SyncManager.Dataset.SynchronizeAsync(System.Threading.CancellationToken). Otherwise it listens to connectivity changes, and will do a sync once the connectivity is back. Note that if this method is called multiple times, only the last synchronize request is kept. If either the dataset or the callback is garbage collected , this method will not perform a sync and the callback won't fire.
This is triggered when the given dataset is deleted remotely. Return true if you want to remove local dataset, or false if you want to keep it.
If two or more datasets are merged as a result of identity merge,
this will be triggered. A list of names of merged datasets' is passed
in. The merged dataset name will be appended with its old identity
id. One can open the merged dataset, synchronize the content,
reconcile with the current dataset, and remove it. This callback will
fire off until the merged dataset is removed.
This can be triggered during two phases. One is when the remote changes are about to be written to local storage. The other is when local changes are uploaded to remote storage and got rejected. Here is an example:
playerInfo.OnSyncConflict = this.HandleSyncConflict; private bool HandleSyncConflict(Dataset dataset, List
Supported in: 4.5, 4.0, 3.5
Portable Class Library:
Supported in: Windows Store Apps
Supported in: Windows Phone 8.1
Supported in: Xamarin Android
Supported in: Xamarin iOS (Unified)
Supported in: Xamarin.Forms
Supported Versions: 4.6 and above
Supported Platforms: Android, iOS, Standalone