The TodoListViewModel
constructor accepts an IDeviceProperties
instance and an ITodoService
instance, which, as you saw in Chapter 32, is used for storage and retrieval of to-do items. See the following excerpt:
public TodoListViewModel(
ITodoService todoService, IDeviceProperties deviceProperties)
{
...
backupDatabaseCommand = new DelegateCommand(obj => BackupDatabase());
restoreDatabaseCommand = new DelegateCommand(obj => RestoreDatabase());
Load();
}
The viewmodel contains a method that leverages the IDeviceProperties
instance to create a unique ID to use to identify itself to calls to a WCF service.
string GetUserId()
{
string id= deviceProperties.WindowsLiveAnonymousId;
if (string.IsNullOrWhiteSpace(id))
{
id= "Emulator";
}
return id;
}
The anonymous ID is passed to the WCF service when backing up the local database file and used as part of the URL when restoring it.
3.17.81.201