BudgetAnalyser.Engine.Services.ApplicationDatabaseService.LoadAsync C# (CSharp) Метод

LoadAsync() публичный Метод

public LoadAsync ( string storageKey ) : Task
storageKey string
Результат Task
        public async Task<ApplicationDatabase> LoadAsync(string storageKey)
        {
            if (storageKey.IsNothing())
            {
                throw new ArgumentNullException(nameof(storageKey));
            }

            ClearDirtyDataFlags();
            var encryptionKey = this.credentialStore.RetrievePasskey();
            this.budgetAnalyserDatabase = await this.applicationRepository.LoadAsync(storageKey);
            if (this.budgetAnalyserDatabase.IsEncrypted && encryptionKey == null)
            {
                throw new EncryptionKeyNotProvidedException($"{this.budgetAnalyserDatabase.FileName} is encrypted and no password has been provided.");
            }

            try
            {
                foreach (var service in this.databaseDependents) // Already sorted ascending by sequence number.
                {
                    this.logger.LogInfo(l => $"Loading service: {service}");
                    await service.LoadAsync(this.budgetAnalyserDatabase);
                }
            }
            catch (DataFormatException ex)
            {
                Close();
                throw new DataFormatException("A subordindate data file is invalid or corrupt unable to load " + storageKey, ex);
            }
            catch (KeyNotFoundException ex)
            {
                Close();
                throw new KeyNotFoundException("A subordinate data file cannot be found: " + ex.Message, ex);
            }
            catch (NotSupportedException ex)
            {
                Close();
                throw new DataFormatException("A subordinate data file contains unsupported data.", ex);
            }

            this.monitorableDependencies.NotifyOfDependencyChange(this.budgetAnalyserDatabase);
            this.monitorableDependencies.NotifyOfDependencyChange<IApplicationDatabaseService>(this);
            return this.budgetAnalyserDatabase;
        }