コード例 #1
0
        public async Task BackupWorkspace(IJSRuntime js, string fileName)
        {
            var localStorageManager = new LocalStorageManager(LocalStorageRepository);
            var backup = await localStorageManager.ExportToZip();

            await js.SaveAs(fileName, backup);
        }
コード例 #2
0
        public async Task ResetWorkspace(IJSRuntime js)
        {
            var localStorageManager = new LocalStorageManager(LocalStorageRepository);
            await localStorageManager.Clear();

            await js.ReloadApplication();
        }
コード例 #3
0
        public async Task HandleFileSelected(IFileListEntry[] files)
        {
            SetProgress();
            await Task.Delay(10);

            try
            {
                var reader = new FileListEntryReader()
                {
                    DataValidation = data => { if (!LocalStorageManager.ValidateZip(data))
                                               {
                                                   throw new InvalidOperationException("Invalid archive format");
                                               }
                    }
                };

                var file = files?.FirstOrDefault();
                Data = await reader.HandleFile(file);

                SetInfo(file.Name);
            }
            catch (Exception ex)
            {
                SetError(ex.Message);
                Data = null;
            }
        }
コード例 #4
0
        public async Task RestoreWorkspace(IJSRuntime js, byte[] data)
        {
            var localStorageManager = new LocalStorageManager(LocalStorageRepository);
            await localStorageManager.Clear();

            await localStorageManager.ImportFromZip(data);

            await js.ReloadApplication();
        }