TodoListViewModel

,

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.62.34