public async Task LoadAsync(ApplicationDatabase applicationDatabase)
{
this.matchingRules.Clear();
this.matchingRulesGroupedByBucket.Clear();
this.rulesStorageKey = applicationDatabase.FullPath(applicationDatabase.MatchingRulesCollectionStorageKey);
List<MatchingRule> repoRules;
try
{
repoRules = (await this.ruleRepository.LoadAsync(this.rulesStorageKey, applicationDatabase.IsEncrypted))
.OrderBy(r => r.Description)
.ToList();
}
catch (FileNotFoundException)
{
// If file not found occurs here, assume this is the first time the app has run, and create a new one.
this.rulesStorageKey = await BuildDefaultFileName();
repoRules = this.ruleRepository.CreateNew().ToList();
}
InitialiseTheRulesCollections(repoRules);
this.monitorableDependencies.NotifyOfDependencyChange<ITransactionRuleService>(this);
NewDataSourceAvailable?.Invoke(this, EventArgs.Empty);
}