コード例 #1
0
ファイル: TopMenuVM.cs プロジェクト: jimfasoline/OpenTracker
        /// <summary>
        /// Opens a file with saved data.
        /// </summary>
        private async Task OpenImpl()
        {
            var dialogResult = await _fileDialogService.ShowOpenDialogAsync();

            if (dialogResult is null)
            {
                return;
            }

            try
            {
                _saveLoadManager.Open(dialogResult);
            }
            catch (Exception ex)
            {
                string message = ex switch
                {
                    JsonReaderException _ => "The selected file is not a valid JSON file.",
                    UnauthorizedAccessException _ =>
                    "The file cannot be read.  Check the permissions on the selected file.",
                       _ => ex.Message
                };

                await OpenErrorBox(message);
            }
        }