/// <summary>
        ///     This method saves the user data both to memory, and subsequently to persistent storage.
        /// </summary>
        private async void SaveData( )
        {
            // Save the user data to memory.
            StaticUserDataStore.UserData = _appUserData;

            // Write the data to persistent storage.
            var fileWriteStream = await _fileStreamRetriever.ObtainFileStreamAsync(StaticUserDataStore.UserFileName, true, FileAccess.ReadAndWrite);

            var writeTask = _userDataStreamWriter.Write(fileWriteStream, _appUserData);

            // Navigate back to previous page upon saving.
            NavigationParameters navigationParameters = new NavigationParameters();

            navigationParameters.Add("userData", _appUserData);
            await _navigationService.GoBackAsync(navigationParameters);
        }
        public async void OnNavigatingTo(NavigationParameters parameters)
        {
            // Attempt to load the user data from the store.
            var userDataFileExists = await _fileStreamRetriever.CanObtainStreamFromPathAsync(StaticUserDataStore.UserFileName);

            if (userDataFileExists)
            {
                // Attempt to load the user data.
                var stream = await _fileStreamRetriever.ObtainFileStreamAsync(StaticUserDataStore.UserFileName, false, FileAccess.Read);

                var appUserData = _jsonObjectStreamReader.Read <AppUserData>(stream);

                // Navigate to the homepage.
                var navigationParameters = new NavigationParameters();
                navigationParameters.Add("userData", appUserData);
                await _navigationService.NavigateAsync("/GNav/MainPage");
            }
            else
            {
                // Load the enter user details page.
                await _navigationService.NavigateAsync("/GNav/MainPage/EditUser");
            }
        }
        private async Task <AppUserData> LoadAppUserDataFromFileAsync(string userFileName)
        {
            var fileReadStream = await _fileStreamRetriever.ObtainFileStreamAsync(userFileName, false, FileAccess.Read);

            return(await _jsonObjectStreamReader.Read <AppUserData>(fileReadStream));
        }