Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="file"></param>
        /// <param name="recoverFileResolver">when null, an exception will be thrown when a recovery would be required</param>
        public void Open(LibraryFilePath file, Func <bool> recoverFileResolver = null)
        {
            try
            {
                this.LoadingState = FileServiceLoadingState.Opening;
                if (this.FilePath != null)
                {
                    throw new FileAlreadyOpenedException();
                }
                this.FilePath = file;
                try
                {
                    this.WorkDirectoryPath = FilePath.UnpackLibrary();
                    validateWorkingDirectory();
                }
                catch (Exception ex)
                {
                    this._logger.LogError(ex, "Unpacking failed, starting recovery");
                    handleRecovery(recoverFileResolver);
                }


                this.LoadingState = FileServiceLoadingState.Open;
            }
            catch (RecoveryCanceledException ex)
            {
                this.LoadingState = FileServiceLoadingState.Closed;
                throw ex;
            }
            catch (Exception ex)
            {
                this.LoadingState = FileServiceLoadingState.Closed;
                this._logger.LogError(ex, "recovery failed");
                throw ex;
            }
        }
Пример #2
0
 public void Close(LibraryFilePath file)
 {
     throw new NotImplementedException();
 }